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

i18n make-pot and minified js files #140

Closed
idea--list opened this issue Feb 4, 2019 · 9 comments
Closed

i18n make-pot and minified js files #140

idea--list opened this issue Feb 4, 2019 · 9 comments

Comments

@idea--list
Copy link

Hi there,

Developing my first block plugins for GB i noticed a strange behaviour i just can not figure out:

If i write a plugin out of scratch then with wp i18n make-pot all the translatable strings will get extracted from all the .js files and after finishing the conversion to .json file and using wp_set_script_translations() the strings originated from .js files get translated just as expected.

However if i am using boilerplates like create-guten-block, then i18n make-pot extracts strings from .js files located under /src/blocks (where we just develop them), but it simply does not extract any strings from the file /dist/block.build.js even after running npm run build. Now that is a problem as WP uses this file in GB editor, but in the .pot file there are no references to this .js file and as a consequense no string located in the production .js file gets translated.

I just wonder if it is because that file is minified.
Can anyone confirm if this is a bug or am i doing something not the right way?

Regards

@schlessera
Copy link
Member

This will probably due to the way the build system for create-guten-blockis set up, I assume the strings are encoded/wrapped in such a way that our parser doesn't detect them.

@swissspidy
Copy link
Member

However if i am using boilerplates like create-guten-block, then i18n make-pot extracts strings from .js files located under /src/blocks (where we just develop them)

That's actually a good thing, because when translators want to see where strings are used, they can just check out the source.

Now that is a problem as WP uses this file in GB editor, but in the .pot file there are no references to this .js file and as a consequense no string located in the production .js file gets translated.

What does the POT file have to do with this?

As long as your JSON files are named textdomain-locale-scripthandle.json then WP will use them for translations just fine.

@idea--list
Copy link
Author

idea--list commented Feb 12, 2019 via email

@schlessera
Copy link
Member

All bug reports are welcome.

Please do me the favor and keep a friendly and constructive attitude, though. @swissspidy is just making sure that your expectations are correct before we spend too much time on going through the code. That is standard procedure for maintaining a complex piece of code like WP-CLI.

If your expectations are indeed the correct ones but you still don't get the result you should, then we will of course further investigate what the issue might be.

Thanks!

@idea--list
Copy link
Author

idea--list commented Feb 12, 2019 via email

@swissspidy
Copy link
Member

It was definitely not my intention to offend you or anything.

It would be really helpful if you could give us more information about your setup, i.e. file names, folder structure, text domain, etc. Because "it won't get translated" is very broad.

https://pascalbirchler.com/internationalization-in-wordpress-5-0/ has a good tutorial of how to get things running.

As I said before, it's probably just an issue of naming your JSON files properly.

@idea--list
Copy link
Author

idea--list commented Feb 12, 2019 via email

@ataylorme

This comment has been minimized.

@swissspidy
Copy link
Member

@ataylorme That sounds really unrelated to the issue at hand here. Would you mind opening a separate one? Thanks in advance! Also note that this should actually work since at least #87. Please verify that you are using the latest version of the package.

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

No branches or pull requests

4 participants