-
Notifications
You must be signed in to change notification settings - Fork 27
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
make isFuzzy return true if tag string includes "fuzzy" #179
Conversation
…gs, includes fuzzy fix ttag-org#178
@AlexMost To my knowledge, it's all backwards compatible. The other PRs: |
Hi @uriesk I'm happy to merge this, code seems OK.
What editor, specifically? What worries me is that a rather reasonable |
@dimaqq
msgid ""
msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
#: src/test.js:10
#, javascript-format
msgid "Hello ${ name }!"
msgstr ""
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Project-Id-Version: PACKAGE VERSION\n"
"PO-Revision-Date: 2024-03-21 17:14+0100\n"
"Last-Translator: uriesk <[email protected]>\n"
"Language-Team: Austrian\n"
"Language: de_AT\n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/test.js:10
#, javascript-format
msgid "Hello ${ name }!"
msgstr "Hallo ${ name }!"
msgid ""
msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
#: src/test.js:10
#, javascript-format
msgid "Hello ${ userName }!"
msgstr ""
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"PO-Revision-Date: 2024-03-21 17:14+0100\n"
"Last-Translator: uriesk <[email protected]>\n"
"Language-Team: Austrian\n"
"Language: de_AT\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/test.js:10
#, fuzzy, javascript-format
msgid "Hello ${ userName }"
msgstr "Hallo ${ name }!" And here it is, it added the fuzzy tag additional to the javascript-format tag. Marking the string, to tell you that you have to check the change (and that is good, cause it is now faulty). And every single editor that uses Currently, ttag is incapable of telling that this is fuzzy.
Every string that is detected as fuzzy is ignored by default. Ordinary Recently there was an option added to tell ttag to also include fuzzy strings: #169 I can't think of any situation where someone would rely on fuzzy javascript-format to be included, but ordinary fuzzy strings not. But it is a change in behavior, so maybe bumping the major version would be good? But i am not familiar in how the versioning is done. |
Unfortunately, I'm working for a different company and I don't have access to the project where I used My gut tells me that GNU gettext was not very good for some reason, and I merged translation files using |
I think last time I did something with this, That being said, I'll be happy to try and reproduce this behaviour. P.S. I couldn't find a reported issue against GNU gettext, is this a bug on their side, or documented, established behaviour? |
@dimaqq It is established behaviour for as long as GNU gettext exist. In the oldest available version on their server from 23 years ago, you can read in its included documentation:
Marking fuzzy strings as fuzzy, is not a bug. But an
If you use weblate or properly even crowdin, msgmerge is already part of the tooling. They watch the repository (with hooks or whatever), detect changes in the .pot file and update the .po files automatically and notify translators that changes arrived (if they want to). |
What I find strange is that |
It's even worse with the references, if you have #: src/test1.js src/haha.js
#: src/lol.js then translationObj.comments.reference becomes 'src/test1.js src/hahajs \nsrc/lol.js' However, since arrays have an |
That's true, but if the variable is a string and (for some reason) contains an entry that contains the string fuzzy, but is not exactly fuzzy, the code will match. |
good that there are no flags that include fuzzy but aren't fuzzy. |
@@ -190,7 +190,8 @@ export function hasTranslations(translationObj) { | |||
export function isFuzzy(translationObj) { | |||
return ( | |||
translationObj && translationObj.comments | |||
&& translationObj.comments.flag === 'fuzzy'); | |||
&& translationObj.comments.flag | |||
&& translationObj.comments.flag.includes('fuzzy')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good enough.
A bit quirky, but I figure that the format of PO files is changed rather rarely.
As a though experiment:
One alternative would be to parse the comment (split on comma, trim whitespace).
Another alternative would be match a more exact pattern.
&& translationObj.comments.flag.includes('fuzzy')); | |
&& translationObj.comments.flag.includes(', fuzzy')); |
Seems like a reasonable PR. Thanks for the contribution @uriesk ! Will try to add some test cases and release the new version ASAP |
The new version is available - [email protected] |
Some editors turn the
#, javascript-format
into#, fuzzy, javascript-format
when they merge.ttag doesn't understand that and doesn't treat them as fuzzy.
fix #178