ISSUE: At theme folter, I'd tried running following commands:
- wp i18n make-pot . languages/text-domain-locale.pot
- wp i18n make-pot . languages/text-domain-locale.pot --slug=text-domain
- wp i18n make-pot . languages/text-domain-locale.pot --domain=text-domain
None of them work with these code in theme:
- __( 'source text', TEXT_DOMAIN );
- _e( 'source text', TEXT_DOMAIN );
SOLUTION: Code must be like the following, Wordpress is also has more functions like these:
- __( 'source text', 'text-domain' );
- _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.