Skip to content

CHILD_TEXT_DOMAIN constant prevents strings being detected #2

@nickcernis

Description

@nickcernis

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:

editing_fr_fr_po_in_developers_ _theme_translations_ _loco_ _wp_dev_ _wordpress

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:

editing_developers_pot_in_developers_ _theme_translations_ _loco_ _wp_dev_ _wordpress

To reproduce

  1. Install and activate Loco Translate.

  2. 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?)

  3. Visit Loco Translate → Themes → Developers → Create Template.

  4. Click the “Create template” button:

    new_template_ _developers_ _theme_translations_ _loco_ _wp_dev_ _wordpress 2

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:

developers_ _theme_translations_ _loco_ _wp_dev_ _wordpress 2

11 strings should be found, but you'll only see 4 if the text domain constant is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions