tipus/po/src/a11y

1 line
38 B
Plaintext
Raw Normal View History

Try to localize Gutenberg to Spanish, as an i18n test Gutenberg uses its own @wordpress/i18n for internationalization, which is not much more than a wrapper around tannin[0], a reimplementation of Jed[1]. It uses the same brain-damaged idea of all JavaScript applications: load a really huge JavaScript object with the source text as key, and the translations, if there are plurals, as values. That is what they call “a gettext localization library”. The problem now becomes: how do i extract the translatable strings from the libraries? Isolated Block Editor’s maintainer stance is very clear: “It’s Gutenberg, so whatever you need to do there will work the same”[2]. In other words, “don’t know; don’t care”. Let’s see what Gutenberg people say. Well, Gutenberg may not require WordPress, but their developers sure assume that you are using WordPress[3], and if you complain then their response is “Why do you think using wp-cli is not easy enough?”[4]. Apparently, before wp-cli they used @wordpress/babel-plugin-makepot, that creates a POT file for each JavasScript processed with WebPack, but does not extract the strings from imported packages. Which is kind of logical, but then where do i get the required JSON files i need to load to translate their fucking overly complex piece of crap? Or, said in another way, how does WordPress do it? Apparently, they do the same they do for every other plugin[5]: with GlotPress[6]. That _would_ work if i used the exact same versions as the plugin does, but it would not help me translate the strings from @automattic/isolated-block-editor because they are **not** a WordPress plugin. And, as we saw previously, the maintainer does not care. Well, i have to extract them myself somehow. Using the uglies hack i could muster, apparently, because wp-cli i18n refuses to extract strings from inside node_modules: create a symlink from each source directory i need to translate into my po folder, and use their beloved wp-cli i18n to create the po, including the strings from my source. Then i downloaded the plugin PO file to include the official translation to Spanish, and wrote a couple to test whether these from Isolated Block Editor were being correctly extracted. However, i can **not** use wp-cli i18n to generate the JSON file because the fucking thing wants to generate a single JSON file for each JavaScript source file, thus generates around 650 JSON files. Are we mad?! The author of Jed recommends po2json and at this point i do not really care if i need yet another fucking tool for this. Just do it, but make sure it is Jed’s 1.x version, otherwise “modern” Gutenberg does not know what to do with the translations. What a shitshow. [0]: https://github.com/aduth/tannin [1]: https://github.com/messageformat/Jed. [2]: https://github.com/Automattic/isolated-block-editor/issues/195#issuecomment-1359566724 [3]: https://github.com/WordPress/gutenberg/issues/14803#issuecomment-479823416 [4]: https://github.com/WordPress/gutenberg/issues/14803#issuecomment-479581903 [5]: https://github.com/WordPress/gutenberg/issues/13535#issuecomment-458678681 [6]: https://developer.wordpress.org/block-editor/contributors/localizing/
2023-06-11 01:50:35 +00:00
../../node_modules/@wordpress/a11y/src