-1

I'm trying to localise a site (Canvas child theme). I already have the translated .po and .mo files.

I uploaded the WooCommerce translation files to child-theme/woocommerce/i18n/languages/ in the child theme and the Canvas translation file to child-theme/lang/. This follows the same directory structure as the parent theme and plugin.

I have also defined WPLANG as 'af_AF'

In my functions.php I have the following function

function weg_localisation() { 
load_theme_textdomain('woothemes', get_stylesheet_directory() . '/lang'); 
unload_textdomain('woocommerce'); 
load_textdomain('woocommerce', get_stylesheet_directory() . '/woocommerce/i18n/languages.woocommerce-af_AF.mo'); 
} 
add_action('init', 'weg_localisation');

Unfortunately I'm having no success with this. Any idea where I'm going wrong?

Thanks,

  • 1
    Shouldn't '/woocommerce/i18n/languages.woocommerce-af_AF.mo' rather be (as you stated above) '/woocommerce/i18n/languages/woocommerce-af_AF.mo'? Note the slash after languages. – tfrommen Mar 28 '13 at 10:19
  • Haha, thanks that worked for the WooCommerce translations. Still having trouble getting the theme textdomain to load. – Dom Mar 28 '13 at 12:23
  • Okay, that's good. As for the theme, what is the exact file name of the MO file? It should be af_AF.mo (and nothing more/less). – tfrommen Mar 28 '13 at 12:48
  • Managed to get it working, see answer below. – Dom Mar 28 '13 at 12:54
1

There was a syntax error in loading the WooCommerce translations and I managed to get the parent theme translations working by following the same method I used for the WooCommerce translations.

function weg_localisation() {
    unload_textdomain( 'woothemes' );
    load_textdomain('woothemes', get_stylesheet_directory() . '/lang/af_AF.mo');
    unload_textdomain('woocommerce');
    load_textdomain('woocommerce', get_stylesheet_directory() . '/woocommerce/i18n/languages/woocommerce-af_AF.mo');
}
add_action('init', 'weg_localisation');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.