diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2012-11-21 06:08:24 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-21 18:23:59 +0100 |
commit | fe8962d3a506a850878401309f81247c80f3d203 (patch) | |
tree | ef90091eb6f7d6eaaddf0ff357f76cf5ddcf768f /src/corelib/tools/qlocale_p.h | |
parent | e7c79face6ec361e4ad0ff8303f1becafac8b2b6 (diff) |
Use likelySubtags to instantiate a locale id from it's short form
...just like described in http://www.unicode.org/reports/tr35/#Likely_Subtags.
This is much more effective than current "guessing" algorithm
+ makes it possible to instantiate a locale by the script or territory code only.
Change-Id: I674f8476e65b01c56960b6e83a1a346df0715274
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/tools/qlocale_p.h')
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 42ef00f821..4d5d918878 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -138,6 +138,28 @@ namespace QIcu { #endif +struct QLocaleId +{ + // bypass constructors + static inline QLocaleId fromIds(ushort language, ushort script, ushort country) + { + const QLocaleId localeId = { language, script, country }; + return localeId; + } + + inline bool operator==(QLocaleId other) const + { return language_id == other.language_id && script_id == other.script_id && country_id == other.country_id; } + inline bool operator!=(QLocaleId other) const + { return !operator==(other); } + + QLocaleId withLikelySubtagsAdded() const; + QLocaleId withLikelySubtagsRemoved() const; + + QString bcp47Name() const; + + ushort language_id, script_id, country_id; +}; + struct QLocaleData { public: |