-
Notifications
You must be signed in to change notification settings - Fork 58
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
Localized strings files are missing strings and adding extra ones #3466
Comments
Is this still an issue for you? The underlying parser was updated a while ago, so I'd expect this to be fixed in WP-CLI 2.5 |
Most likely not because we actually forcing use the last version of WP-CLI (2.5) on this command but let me do a quick check before confirming it. |
I've just verified that the issue is no longer happening 🎊 , at least with the chain operator but I noticed that the parsing fails on files that contain the fragment short syntax Missing stringsThis issue has been fixed by using the last version of WP-CLI that was incorporated in this PR. Extra stringsThis issue has been fixed in this PR. As a side note, we're still using the cached version of the Gutenberg localizations that was fetched for version |
@swissspidy Heads-up that I opened a new issue because looks like we still have a high number of missing translation after the fixes: |
For further details on bug that requires this manual change, see: #3466
Describe the bug
For each platform we generate a specific file with the localized strings:
I investigated further the process of generating these files and I noticed the following issues:
Missing strings
Comparing the files generated in the latest releases, I saw that some strings were missing, for example, the string
Block copied
is present in version1.51.1
but not in1.52.0
, here is the diff of the commit that introduced the change.I debugged the scripts that we use for extracting the strings from the codebase and looks like that some files are not including their strings. Specifically, when we run the command with the debug option (
npm run makepot:ios -- --debug
), we can see that some files can't be parsed (see attached logs). This is caused due to the use of the optional chaining operator that is not supported by the script (this is known bug) we use to extract the strings (wp i18n make-pot
).Parse file errors generated by npm run makepot:ios
Solution
Until the issue gets fixed, the only solution I see is to stop using the optional chaining operator, at least on files where we have localized strings 😞 . Another approach would be to add the strings generated by those files manually (there're 38 files affected by this).
As an alternative, I tried to use a babel plugin that we have in the Gutenberg repo (
@wordpress/babel-plugin-makepot
) for this but unfortunately, it's not including all the strings.I saw that in the web version, we use optional chaining in the code and since the translations are being generated properly, I'm wondering what they do differently, so I'll investigate further if we could replicate partially that process 🤔
Extra strings
Similar to the previous issue, comparing the generated files from previous releases, I noticed that we recently added a lot of strings that are not even being used in the native version, here you can check that we introduced 538 new strings 😲 .
Before generating the localized string files, we make an intermediate
POT
file, I checked manually this file and I found that some strings are extracted from files that aren't*.native.js
files, even including PHP files 😮 .As per the documentation of
wp i18n make-pot
, the argument--include
should only include the specified files, however, this is not working as expected and I found out that is a known bug.Solution
We could explicitly exclude the files that we don't want to include through the
--exclude
argument, in this case, we could add*.js
and*.php
.The commands will result in the following:
To Reproduce
npm run genstrings
Expected behavior
The localized strings file should only contain the strings extracted from
*.native.js
files.The text was updated successfully, but these errors were encountered: