Skip to content
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

make-json: generated file missing theme textdomain prefix #197

Closed
mcguffin opened this issue Nov 27, 2019 · 2 comments · Fixed by #313
Closed

make-json: generated file missing theme textdomain prefix #197

mcguffin opened this issue Nov 27, 2019 · 2 comments · Fixed by #313

Comments

@mcguffin
Copy link

Bug Report

I'll keep it brief – might hopefully save someones time. ;)

Translations folder in a theme – just as expected by load_theme_textdomain():

languages/
    theme-slug.pot
    de_DE.po
    de_DE.mo

CLI Command

wp i18n make-json languages/*.po --no-purge

The result

languages/
    theme-slug.pot
    de_DE.po
    de_DE.mo
    languages/de_DE-a0623ef93657e56554c5ddda522ed690.json

The translation will not load.
wp_set_script_translations() expects the file to live in {textdomain}-{locale}-{md5}.json.
After renaming it accordingly the translation loads.

@swissspidy
Copy link
Member

Related: #151 (comment)

@swissspidy
Copy link
Member

Just copying my comment from the above ticket, which still seems accurate:

wp i18n make-json does indeed not support a --domain because it is actually not used. That is indeed problematic.

The script just turns <source>.po into <source>-hash.json, which does not work as you mentioned.

I think the solution here should be:

  1. Check --domain argument for text domain
  2. If not passed, check PO file for X-Domain header.
  3. Prefix JSON file with text domain in case it is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants