Open kkmuffme opened 2 years ago
This is an ambiguous case, because it's not clear whether the translator comment is meant for the first call or the second. What if both your __()
calls contained translator comments for example?
I'd recommend writing these statements on multiple lines. This will help both developers and tools like this CLI command.
This is an ambiguous case, because it's not clear whether the translator comment is meant for the first call or the second.
Even then, translators comments should not be applied to multiple strings. Can you please quickly check the old issue https://github.com/wp-cli/i18n-command/issues/154 as we already discussed this exact problem there.
What if both your __() calls contained translator comments for example?
Apply the translators comments in the order they appear to the strings in the order they appear.
If I have x translators comments, but x+y strings, then apply the translators comments in the order they appear but skip strings that do not match the placeholders (and apply the translators comment to the next string where the placeholders match).
I'd recommend writing these statements on multiple lines.
See https://github.com/wp-cli/i18n-command/issues/154#issuecomment-873967798 (and the previous one) I only checked PHP. Maybe this works correctly in JS already? (and the PHP-gettext bug-fix is buggy)
There will always be ambiguity when there are multiple i18n functions on a single line, because there can only be 1 preceeding translator comment on the line before.
Using multi-line statements is a reasonable workaround to avoid all potential issues. Have you tried that?
Translators comments should still only be applied once.
Using multi-line statements is a reasonable workaround to avoid all potential issues. Have you tried that?
Yes, in some cases that isn't possible though, as it would make maintenance much harder. e.g. I have about 20 email templates for about 15 different websites, which all contain identical and non-identical markup. Changing it to multi-line is tons of work, but mostly it will make maintenance harder - if I want to check for a specific markup string to change everywhere, I now have to do a multi-line regex search and a multi-line replacement.
Bug Report
WP-CLI 2.7.0-alpha-9fcc59a
https://github.com/wp-cli/i18n-command/issues/154 is partially back (or maybe never fully fixed?)
Will give error:
in the .pot I see:
Issues: 1) the translators comment is applied to multiple strings, instead of only to the strings that has that placeholder (%1$s)/the first string 2) the error message only contains the first location/line number in that file instead of all