diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2011-03-09 11:34:25 (GMT) |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2011-03-09 13:52:56 (GMT) |
commit | d4250d9e1d4ed23e0cf41e6ce35d9dda6323455c (patch) | |
tree | 35f25380afa3adeddf9aceff0da470b39fec623d /mkspecs/common/symbian/symbian.conf | |
parent | 796b084fbaaeeacbb6af7b3a2d132b5900c3db62 (diff) | |
download | Qt-d4250d9e1d4ed23e0cf41e6ce35d9dda6323455c.zip Qt-d4250d9e1d4ed23e0cf41e6ce35d9dda6323455c.tar.gz Qt-d4250d9e1d4ed23e0cf41e6ce35d9dda6323455c.tar.bz2 |
Implement language fallback logic for localize_deployment
When querying system locale it does return both language and country,
so sometimes users want to have both in their .ts file names
(e.g. myapp_zh_CN.ts). This is bit problematic in Symbian, where
there are separate language codes for only very few language +
country combinations. Until now, the unsupported combinations were
simply dropped from deployment localization.
More proper way to handle these unknown language + country combinations
is to fall back to using the plain language code for them instead of
dropping them altogether. This is somewhat analogous to how
QTranslator::load() loads .ts files if it can't find the file for
specified language + country combination.
E.g. User defines:
TRANSLATIONS += myapp_zh_CN.ts myapp_zh_HK.ts myapp_zh_TW.ts
There are separate Symbian language codes for HongKong Chinese
(zh_HK = 30) and Taiwanese Chinese (zh_TW = 29), but rest of the world
is expected to use just Chinese (zh = 31). This means "zh_CN" mapping
is not provided as it would be same as plain "zh".
With this fix, qmake will now automatically generate a fallback
mapping from "zh_CN" to "31" for deployment localization purposes, and
is able to read application captions and pkg names from myapp_zh_CN.ts.
If there are multiple TRANSLATIONS defined that would result in same
Symbian language code, only the first one is used.
Task-number: QTBUG-17927
Reviewed-by: Oswald Buddenhagen
Diffstat (limited to 'mkspecs/common/symbian/symbian.conf')
-rw-r--r-- | mkspecs/common/symbian/symbian.conf | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index 65e6aa0e8..5f5c7e1 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -230,16 +230,41 @@ defineReplace(symbianRemoveSpecialCharacters) { # Determines translations that are Symbian supported defineTest(matchSymbianLanguages) { + # Qt language codes for which we need to parse .ts file SYMBIAN_MATCHED_LANGUAGES = + # List of translation files for matched languages SYMBIAN_MATCHED_TRANSLATIONS = + # List of Qt language codes for which we have no mapped Symbian code but we have a fallback code + # and therefore need to generate a mapping for in localize_deployment.prf. + # The fallback code means plain language code for languages that have both language and country codes. + # E.g. the fallback code for language "zh_CN" would be "zh". + SYMBIAN_UNMAPPED_LANGUAGES = + # List of handled Qt language codes to avoid duplicate Symbian language codes in case both + # unmapped language+country combination and its fallback code, or multiple unmapped language+country + # combinations that have same fallback code are included. + HANDLED_LANGUAGES = # Cannot parse .ts file for language here, so detect it from filename. # Allow two and three character language and country codes. for(translation, TRANSLATIONS) { language = $$replace(translation, "^(.*/)?[^/]+_(([^_]{2,3}_)?[^_]{2,3})\\.ts$", \\2) - contains(SYMBIAN_SUPPORTED_LANGUAGES, $$language) { - SYMBIAN_MATCHED_LANGUAGES += $$language - SYMBIAN_MATCHED_TRANSLATIONS += $$translation + !contains(HANDLED_LANGUAGES, $$language) { + HANDLED_LANGUAGES += $$language + contains(SYMBIAN_SUPPORTED_LANGUAGES, $$language) { + SYMBIAN_MATCHED_LANGUAGES += $$language + SYMBIAN_MATCHED_TRANSLATIONS += $$translation + } else { + # No direct mapping for specified language found. Check if a fallback language code can be used. + strippedLanguage = $$replace(language, "_.*$",) + contains(SYMBIAN_SUPPORTED_LANGUAGES, $$strippedLanguage):!contains(HANDLED_LANGUAGES, $$strippedLanguage) { + HANDLED_LANGUAGES += $$strippedLanguage + SYMBIAN_UNMAPPED_LANGUAGES += $$language + SYMBIAN_MATCHED_LANGUAGES += $$language + SYMBIAN_MATCHED_TRANSLATIONS += $$translation + SYMBIAN_LANGUAGE_FALLBACK.$$language = $$strippedLanguage + export(SYMBIAN_LANGUAGE_FALLBACK.$$language) + } + } } } @@ -247,6 +272,7 @@ defineTest(matchSymbianLanguages) { export(SYMBIAN_MATCHED_LANGUAGES) export(SYMBIAN_MATCHED_TRANSLATIONS) + export(SYMBIAN_UNMAPPED_LANGUAGES) } # Symbian pkg files that define multiple languages require a language specific string to be |