-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CHILD_TEXT_DOMAIN constant prevents strings being detected #2
Comments
Thank you, Nick. You are correct. If you want to automatically generate the theme's However, I'm teaching a different way of building themes and plugins to be both modular and configurable. That means we need a different way to generate the New ApproachWith this new ModularConfig approach, we will build the There's a flaw in the architectural methodology of making developers have to duplicate code over and over again just for building the I'll be teaching and covering that within the next Theme Development A-Z course and am teaching it now in the Plugin Development A-Z course. I know it's a departure and different. But I'm working to teach folks how to save themselves a lot of time and costs to flourish and grow their careers and businesses. Notes are neededI will write an article about it and make a note in the labs for to ensure that folks know that you cannot build a Thank you for pointing out that I need to make this clear for folks. Cheers, |
I really like your config-based approach, and I can see how generating the pot file with gulp or similar might work around the general advice in the WordPress community not to use a variable/constant. For what it's worth, Poedit found all strings using the “Translate WordPress theme” option even with the constants in place; it was just Loco that struggled to do the same. |
Thanks, Nick. That's awesome you ran the test with Poedit for me. Thank you so much! I really appreciate you taking the time and digging into it. Yes, I was going to teach folks both Poedit and Gulp task to build the Cheers and thanks again! :) |
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'.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.php
inside 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.
The text was updated successfully, but these errors were encountered: