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

All: Fix undefined errors in translations #11407

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

wh201906
Copy link
Contributor

Some original strings don't have %s, but the corresponding translations included it. This mismatch causes the text undefined to appear in the UI.

image
image

Some original strings don't have %s, but the corresponding translations
included it.
@wh201906
Copy link
Contributor Author

This could also occurs in other translations. I did a rough search with regular expression ^msgid(?!.*%s).*\nmsgstr.*%s and ^msgid(?!.*%d).*\nmsgstr.*%d. Here are the results.

图片

图片

@laurent22
Copy link
Owner

That's a good catch, thank you. We have a script to check the translations in validate-translations.js but looks like the msgfmt tool doesn't catch these errors. I've also tried the --check-format flag and that didn't make a difference. I guess we should add your regex to the check to prevent such strings being inserted.

@laurent22 laurent22 merged commit a6e8774 into laurent22:dev Nov 18, 2024
7 checks passed
@wh201906 wh201906 deleted the wh201906/i18n_zh branch November 19, 2024 03:21
@wh201906
Copy link
Contributor Author

wh201906 commented Nov 19, 2024

@laurent22 I tried msgfmt --check-format and found it works for the mismatched string only when the string is marked with c-format. Also, if the string is marked with fuzzy, the mismatch won't be reported.


For example, on commit 546c75b, I can get two mismatched strings in packages/tools/locales/hu_HU.po
图片
图片

When running msgfmt -v --check-format, it doesn't show any errors.
图片


However, if I add #, c-format to the string, the msgfmt will report the mismatch as an error.
图片
图片


If I change #, fuzzy to #, fuzzy, c-format, the msgfmt won't report the mismatch, which is reasonable.
图片
图片


Maybe the built-in check of msgfmt is better than the custom regular expressions?

@wh201906
Copy link
Contributor Author

This could also occurs in other translations.

Based on the facts I just discovered I think we should ignore the strings marked with fuzzy. Here are the new regular expressions for test:
#(?!, fuzzy).*\nmsgid(?!.*%s).*\n(msg.+\n)*msgstr.*%s
#(?!, fuzzy).*\nmsgid(?!.*%d).*\n(msg.+\n)*msgstr.*%d

And here are the results:
图片
图片

@laurent22
Copy link
Owner

Thanks for looking into this @wh201906. So it means that we should somehow mark the strings as "c-string" to get this msgfmt tool working?

@wh201906
Copy link
Contributor Author

Yes. But I'm not sure if this is good for Joplin. Normally xgettext could handle the c-format comment automatically, but I found you have switched fromxgettext to gettext-extractor for some reasons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants