Hyrda: Translate logo image in Polylang? | BoldGrid
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #23822 Reply

    I want to have a “logo” image that includes my site name, but my site is bilingual (English & Japanese), using the Polylang plugin. How can I specify a different logo image for the two languages? By the way, I’m using a child theme and know web development; what I don’t know is how your theme is constructed.

    #23825 Reply
    Harry J
    Keymaster

    Hello Karen,

    Thank you for your question about child theming with BoldGrid.

    According to the documentation from Polylang, you can use conditional arguments to accomplish changing the logo based upon the language.

    https://polylang.pro/doc-category/developers/

    This would be something you can apply in the header template using a child theme. Keep in mind, adding this type of conditional will also override the Customizer controls for the logo, as it would require the image(s) being used to be hard-coded into the header template. We do have detailed documentation on using the configuration file to set the header template in use.

    https://www.boldgrid.com/docs/

    I hope this helps you to accomplish your goal!

    Thanks,

    Harry J.

    #23824 Reply

    Thank you for your reply. Your first link didn’t really point to a specific instruction, but just the index of a few “how to” articles, none of which were applicable. But doing more reading and digging, I tried three things:

    (1) I eventually found this page: https://polylang.pro/a-multilingual-custom-header-image/

    Following their instructions, I created a wp-content/polylang directory and put a wpml-config.xml in it with the following content:

    <wpml-config>
    <admin-texts>
    <key name=’theme_mods_boldgrid-hydra-child’>
    <key name=’header_image’ />
    </key>
    </admin-texts>
    </wpml-config>

    But its instructions don’t work for your theme. First, Step 3 is impossible because when BoldGrid is running, there is no Appearance menu in the admin area – your plugin replaces many of the standard WP menu items with special stuff. Secondly, if it should be assumed that I already have a header image set (because I can see one), Step 4 does not work – no string related to header images appears in Strings Translation. If you know how I should get this to work, this is the most preferred method, because future changes to images can be done within the WordPress interface, rather than having to use the hoster’s control panel or FTP. Perhaps it is as simple as changing one or both of the key names to match Hydra terms.

    (2) The next thing I tried was to copy templates/header/header.php into the same location of the child theme, and edit it. I can see where the logo goes (header-6), but I don’t know what I should replace `<?php do_action( ‘boldgrid-theme-location’, ‘header’, ‘6’ ); ?>` with, as I can only imagine what that function call does (somehow fetch the site title/tagline vs. logo image settings and then echo the appropriate HTML tag like <img>). If this is the method I should use, more instruction about what to put there would be helpful. Do I just hardcode a conditional based on the current language and two <img> tags? If so, future changes to the images cannot be done using the WordPress interface, because the image file path would change, so someone would have to always remember that the reference must be changed in header.php.

    (3) Finally, I tried to understand the instructions in your linked page about the BoldGrid config file, but I don’t think I did. In the child theme, I mimicked the path to config.php in the parent (…/inc/boldgrid-theme-framework-config), copied the config.php file from the parent, and edited it to have this:

    if (get_locale() == ‘en_US’) {
    $boldgrid_framework_configs[’template’][’header’] = ‘generic’;
    } else {
    $boldgrid_framework_configs[’template’][’header’] = ‘2’;
    }

    Then I created a templates/header/header-2.php file and made a visible modification to it. There was no reaction – header-2.php is not used when the locale was ja-JP.

    This seems like a simple thing, but it’s really turning out to be a challenge. I look forward to your continued help.

    #23823 Reply
    Harry J
    Keymaster

    Hi Karen!

    I am sorry to hear you are still having this issue. Regarding the template functions, not all of them are defined within the header on every theme but they are set up in the header to help speed up development time. You can find the array used to set the functions on lines 34-40, and header-7 is used for the social menu in Hydra

    https://github.com/BoldGrid/hydra/blob/master/inc/boldgrid-theme-framework-config/config.php

    A good way to approach this is to use print_r first, to ensure the correct language slug is being queried: To give you an idea of how I got it to work, I have included my header template in this screenshot

    Finally, I was able to set up Polylang on a test site and created translations for my home page for two languages, and this worked fine for me:
    https://pastebin.com/JcvrbBnH

    Basically, I just replaced the header-6 function for site-identity with my conditional that checks for the language. Here is a screenshot of that page as well

    I hope this helps you accomplish your goal.

    Have a great day!

    Harry J.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Hyrda: Translate logo image in Polylang?
Your information: