-
Notifications
You must be signed in to change notification settings - Fork 4
I it necessary to add the text domain in gettext calls? #3
Comments
Great question! I‘d argue the handbook is wrong in that case. Gutenberg itself omits the text domain for various reasons, one being that the code is used in WordPress core. But it‘s considered a best practice to always pass it. I actually wrote a detailed explanation for that on my blog: https://pascalbirchler.com/text-domain-wordpress-internationalization/ |
Thanks for your answer, correct if I am wrong but your article is only dealing with PHP gettext calls right? maybe JS ones don't need them for some reason? |
also one more question if the wp i18n command already scans js files, why do we need @wordpress/babel-plugin-makepot to scan js files and then merge php and js translations with wp i18n? why not use wp 18n directly? |
No, it also applies to JavaScript files. In the end it boils to what you‘re developing. If you‘re developing a WordPress plugin and use the WP I18N package for internationalization, there‘s no need to use that Babel plugin at all. That plugin was like an intermediate solution for everything. It‘s basically outdated now. You can now just use the WP-CLI command to generate everything. |
Thanks a lot :) |
Opened an issue in the Gutenberg repository to improve the documentation: WordPress/gutenberg#12502 |
Hello, in your code here I can see that you use the text domain as a second argument for __, but in the Gutenberg handbook it's mentioned that you can put it but you don't have to. Do you have any idea if it's necessary or not and if not why do we have the option to put it?
The text was updated successfully, but these errors were encountered: