Details
-
Task
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5
-
None
-
-
13
-
Foundation PM Prioritized
Description
At present we use QLocale objects to identify translations (and, I gather, voices for text-to-speech output). Unfortunately, this limits us to (language, script, territory) triples for which CLDR has data; if the combination you ask for isn't in CLDR, QLocale will replace some of your choices (starting with any wildcards, the Any members of enums) with alternatives (selected via CLDR's "likely sub-tag" rules) to obtain a triple for which it does have data. This is fine for QLocale itself, but suboptimal for translations (and other similar selectors, such as text-to-speech's voice), where the set of available triples is different.
The correct thing to do for this is to break out the "pick as close a match as we can" logic from QLocale into a QLocaleSelector that packages a test for availability of data with knowledge of the likely sub-tag rules to produce an object to which you pass a proposed triple and get back a best match for which data is available. Then QLocale can use this with "do we have CLDR data for it" test, QTranslator can use it with "do I have a translation available" and text-to-speech can use it with "do I have a voice available".
The result of that (and the triple passed to the query) would in practice be a QLocaleId object; this is currently private, so we would either need to wrap it in some public façade type, that exposes only queries for the language, script and country, perhaps also QLocaleId::name(), or prepare it to be made public. If something like QLocaleId is to become public, it should have a variant field that is currently zero, ready for the eventual resolution of QTBUG-81051, which shall need that field.
Attachments
Issue Links
- relates to
-
QTBUG-117760 Qt Designer start with japanese language as default
- Reported
-
QTBUG-47892 QLocale("es").nativeLanguageName() is "español de España"
- Reported
-
QTBUG-131894 qtranslator loads wrong locale
- Open
-
QTBUG-126139 Linguist shipped with Qt6 breaks how language tag is handled
- Closed
-
QTBUG-121418 [Regr: 5.x -> 6.x] QTranslator loads zh instead of zh_TW translation
- Reported
-
QTBUG-113517 Implement ECMA-402-compatible l10n in V4
- Reported
-
QTBUG-107781 Norwegian macro language code 'no' not picked up by QTranslator
- Reported