-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Current behaviour
The use of the CHILD_TEXT_DOMAIN constant prevents detection of strings by tools such as Loco Translate.
Some translation tools statically analyse files for translation, so CHILD_TEXT_DOMAIN is never parsed by PHP to become 'developers'.
- https://markjaquith.wordpress.com/2011/10/06/translating-wordpress-plugins-and-themes-dont-get-clever/
- http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/
- https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#text-domains (note red “do not use variable names” warning)
Loco Translate detects only four strings in the theme when trying to create a template file, for example (the ones in stylesheet header) – all of the strings passed to __() are missing:
Expected behaviour
CHILD_TEXT_DOMAIN is replaced with a string literal such as 'developers', so that translation tools can detect all strings for translation.
If I find , CHILD_TEXT_DOMAIN and replace with , 'developers', Loco Translate can then find the strings when building the .pot file:
To reproduce
-
Install and activate Loco Translate.
-
Create a blank folder named 'languages' in the 'developers' directory. (The theme should probably include this by default, perhaps with a blank
index.phpinside so it's saved by git?) -
Visit Loco Translate → Themes → Developers → Create Template.
-
Click the “Create template” button:
The developers.pot template file will be created in the theme's language directory. You can view it directly and count the strings, or see how many strings were detected by clicking “Edit Template” next to the Developers theme in Loco Translate:
11 strings should be found, but you'll only see 4 if the text domain constant is used.


