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

Translators comment audit - tell me in which files the different comment is #227

Closed
kkmuffme opened this issue Sep 13, 2020 · 6 comments · Fixed by #318
Closed

Translators comment audit - tell me in which files the different comment is #227

kkmuffme opened this issue Sep 13, 2020 · 6 comments · Fixed by #318

Comments

@kkmuffme
Copy link

I have 1000s of files (from different projects that share a text-domain since its the same theme and texts just with slightly different design) with this string:
'Hi %s'

I get the following error:
Warning: The string "Hi %s," has 3 different translator comments. (some/file.php)

Since wp-cli knows in which these different translator comments are, could you please also output this info to the user?
Since I have about 7 of these warnings, it would take weeks to sift through all files and check where/what is different, since sometimes strings are on the same line, sometimes on the previous,...

@swissspidy
Copy link
Member

Interesting suggestion!

Since wp-cli knows in which these different translator comments are, could you please also output this info to the user?

I don't think it's as easy as that.

Warnings like that are printed once all the processing is done and all translations have been extracted.

For example:

If you have the same string used in 10 different files, but in one of the files it uses a different comment, we don't know which file that is.

We only know the 10 file names, and the list of comments, but not which comment belongs to which file.

Since I have about 7 of these warnings, it would take weeks to sift through all files and check where/what is different, since sometimes strings are on the same line, sometimes on the previous,...

I don't think it takes that long :-)

Searching for a string in your IDE will quickly show an overview of all occurrences, and then you scan scan through the comments. And the POT file contains all file names too.

@kkmuffme
Copy link
Author

If you have the same string used in 10 different files, but in one of the files it uses a different comment, we don't know which file that is.

Ah ok, so the underlying tool doesnt report that - makes sense why you cannot report, which files are incorrect.

We only know the 10 file names, and the list of comments, but not which comment belongs to which file.

That would actually be sufficient too! Just output the different translators comments, instead of just "3 different translator comments." This would make fixing these issues massively easier - talking from days to 10 minutes, since I can just search for the translators comment.
Would really appreciate if you could change this, as I guess it's just a small tweak to output the comments in the error message.

I don't think it takes that long :-)
Searching for a string in your IDE will quickly show an overview of all occurrences, and then you scan scan through the comments. And the POT file contains all file names too.

Unfortunately, it really does take ages. Since translators comments can be added in various ways (same line, previous line, phpdoc comment style, comment style,...) this means each and every string occurence has to be checked.
It takes about 10 seconds per string occurence in 1000s of file. This means each string error will roughly take 1 working day to fix (I've fixed one and that took me almost a day, then I started to just ignore the error for now)

@swissspidy
Copy link
Member

swissspidy commented May 2, 2022

In #318 I made the output as follows:

$ wp i18n make-pot foo-plugin
Plugin file detected.
Warning: The string "Hello World" has 2 different translator comments. (foo-plugin.php:7, foo-plugin.php:10)
translators: Translators 1!
Translators: Translators 2!
Success: POT file successfully generated!

Before:

$ wp i18n make-pot foo-plugin
Plugin file detected.
Warning: The string "Hello World" has 2 different translator comments. (foo-plugin.php:7)
Success: POT file successfully generated!

@kkmuffme
Copy link
Author

kkmuffme commented Jul 5, 2022

Thank you. Is this available in the latest nightly already?

@swissspidy
Copy link
Member

Not sure. But wp package install wp-cli/i18n-command:dev-main should work.

@kkmuffme
Copy link
Author

kkmuffme commented Jul 5, 2022

Doesn't work unfortunately. Tried wp package install wp-cli/i18n-command too, but neither works for me. I mean it installs fine, just the errors are still the same as before installation.

It shows up fine, but it doesn't work:

wp package list --allow-root
+---------------------+-----------------+----------+-----------+----------------+
| name                | authors         | version  | update    | update_version |
+---------------------+-----------------+----------+-----------+----------------+
| wp-cli/i18n-command | Pascal Birchler | dev-main | available | 2.x-dev        |
+---------------------+-----------------+----------+-----------+----------------+

I'm on WP-CLI 2.7.0-alpha-dc3beef

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