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

Translation not loaded because their name are over specified #2120

Open
shenlebantongying opened this issue Feb 3, 2025 · 1 comment
Open

Comments

@shenlebantongying
Copy link
Collaborator

shenlebantongying commented Feb 3, 2025

Summary:

We should make translation filenames shorter but no shorter than necessary (and the format should follow bcp47)

  • Delete country codes if unnecessary (e.g. ar_SA -> ar).
  • Merge a few unnecessary variants (de_*, es_*...)
  • Rename zh_CN to zh_Hans and zh_TW to zh_Hant.
  • This works everywhere.

The problem is that QTranslator::load's algorithm, https://doc.qt.io/qt-6/qtranslator.html#load-1.

It will remove elements from the back of the lang code. If a translation file is over-specified and user have a different territory code, it won't load.

For example:

If user has system locale ar_QA (Arabic - Qatar), then the QTranslator will try (ar_QA, ar). The ar_SA that we have will be ignored because it is over-specified (Just ar is good.).


Sample other projects:

Related doc:

Previous issue

@shenlebantongying shenlebantongying changed the title Delete country code from translation files if there is no variant Delete country code from translation files if there is no meaningful variant Feb 3, 2025
@shenlebantongying
Copy link
Collaborator Author

shenlebantongying commented Feb 3, 2025

macOS

.

The QLocale::system().uiLanguages() is QList("zh-Hans-CA", "zh-CA", "en", "en-Latn-US", "en-US", "en-CA", "en-Latn-CA").

Linux/KDE and Windows

QLocale also returns a triplets. QLocale::system().uiLanguages() returns QList("zh-CN", "zh-Hans-CN", "zh").

.

https://learn.microsoft.com/en-us/globalization/locale/standard-locale-names

@shenlebantongying shenlebantongying changed the title Delete country code from translation files if there is no meaningful variant On macOS, QLocale will detect bcp47 -> lang-script-territory that causes interface to have inconsistent languages Feb 3, 2025
@shenlebantongying shenlebantongying changed the title On macOS, QLocale will detect bcp47 -> lang-script-territory that causes interface to have inconsistent languages On macOS, QLocale will detect bcp47 lang code format -> lang-script-territory that causes interface to have inconsistent languages Feb 3, 2025
@shenlebantongying shenlebantongying changed the title On macOS, QLocale will detect bcp47 lang code format -> lang-script-territory that causes interface to have inconsistent languages Translation not loaded because their name are over specified Feb 3, 2025
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

No branches or pull requests

1 participant