• Resolved jrstaatsiii

    (@jrstaatsiii)


    Hey there. I have localized a few different elements of our theme that were hardcoded, and have the corresponding .po and .mo files in a language folder. We also have properly set up a call to load_theme_textdomain after theme setup. How do we get PolyLang to recognize the changes and thus translate these text bits when the user changes the language?

    Rich

    http://wordpress.org/plugins/polylang/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Chouby

    (@chouby)

    If your theme is correctly internationalized and localized, you just have to create the language in Polylang and it will do all what is necessary to load the correct language.

    Thread Starter jrstaatsiii

    (@jrstaatsiii)

    will it show up in the “strings translation” tab in polylang settings, or replace the text with the replacement text provided in the .mo and .po files?

    Rich

    Thread Starter jrstaatsiii

    (@jrstaatsiii)

    Here is what I have chouby:

    in functions.php:

    function ssm_localize_theme() {
    
    	    // Retrieve the directory for the localization files
    	    $lang_dir = CHILD_DIR . '/languages';
    
    	    // Set the theme's text domain using the unique identifier from above
    	    load_theme_textdomain('zoll', $lang_dir);
    
    	} // end ssm_localize_theme
    	add_action('after_setup_theme', 'ssm_localize_theme');

    And then where necessary I have the items localized in the theme, like so:

    <div class="language-picker">
    
    	<h4><?php _e('Choose Your Preferred Language', 'zoll'); ?></h4>
    
    	<?php pll_the_languages(array('dropdown'=>1));  ?>
    
    </div>

    Is this not correct?

    Plugin Author Chouby

    (@chouby)

    If CHILD_DIR is defined with get_stylesheet_directory(), and if ‘zoll’ is a unique textdomain name (not the same as parent theme), then it looks correct.

    Did you po/mo files in the CHILD_DIR . '/languages' directory? Did you name your files with only the locale (example fr_FR.mo or de_DE.mo)?

    You can check if the problem comes from Polylang or from your child theme by de-activating Polylang and adding the line:
    define('WPLANG', 'fr_FR');
    in wp-config.php (replace ‘fr_FR’ by your own locale(s) )

    Thread Starter jrstaatsiii

    (@jrstaatsiii)

    yup, the .mo files were not saved with the proper names. thank you for the push in the right direction. -Rich

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Localized Files’ is closed to new replies.