From fe8962d3a506a850878401309f81247c80f3d203 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 21 Nov 2012 06:08:24 +0200 Subject: 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 --- src/corelib/tools/qlocale_p.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/corelib/tools/qlocale_p.h') 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: -- cgit v1.2.3