3

ISSUE: At theme folter, I'd tried running following commands:

  1. wp i18n make-pot . languages/text-domain-locale.pot
  2. wp i18n make-pot . languages/text-domain-locale.pot --slug=text-domain
  3. wp i18n make-pot . languages/text-domain-locale.pot --domain=text-domain

None of them work with these code in theme:

  1. __( 'source text', TEXT_DOMAIN );
  2. _e( 'source text', TEXT_DOMAIN );

SOLUTION: Code must be like the following, Wordpress is also has more functions like these:

  1. __( 'source text', 'text-domain' );
  2. _e( 'source text', 'text-domain' );

Then the command:

  • wp i18n make-pot . languages/text-domain-locale.pot --domain=text-domain

Next, you can just rename .pot into .po and put in wp-content/languages/theme/text-domain-locale.po

We need to translate all items in the file then compile into .mo file:

  • wp i18n make-mo wp-content/languages/theme/text-domain-locale.po wp-content/languages/theme/text-domain-locale.mo

At this time, your theme can switch to the target language for translated text.

I hope lost soul will find a way out earlier! Don't overnight like me :)!

Note: use get_locale() in theme to get current language locale code.

Cskt Coop
  • 41
  • 2

0 Answers0