summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-04-24 23:42:47 +0200
committerEike Rathke <erack@redhat.com>2013-04-25 00:01:07 +0200
commit4806df614a0e7e499aef3d10f77923f189207205 (patch)
treec936d3e57e4f497052ac618b1017801425a378cb
parent3ca2240e4818a554d290ca46536dddcf3d18d332 (diff)
added LanguageTagIcu::getIcuLocale() with additional variant
Change-Id: I5a5689f449ac7653bb716f2ce67ea1039fe2559c
-rw-r--r--i18nlangtag/source/languagetag/languagetagicu.cxx11
-rw-r--r--include/i18nlangtag/languagetagicu.hxx12
2 files changed, 23 insertions, 0 deletions
diff --git a/i18nlangtag/source/languagetag/languagetagicu.cxx b/i18nlangtag/source/languagetag/languagetagicu.cxx
index 6f426d6a67c8..e088b3cd5d2e 100644
--- a/i18nlangtag/source/languagetag/languagetagicu.cxx
+++ b/i18nlangtag/source/languagetag/languagetagicu.cxx
@@ -33,4 +33,15 @@ icu::Locale LanguageTagIcu::getIcuLocale( const LanguageTag & rLanguageTag )
OUStringToOString( rLanguageTag.getBcp47(), RTL_TEXTENCODING_ASCII_US).getStr());
}
+
+// static
+icu::Locale LanguageTagIcu::getIcuLocale( const LanguageTag & rLanguageTag, const OUString & rVariant )
+{
+ /* FIXME: how should this work with any BCP47? */
+ return icu::Locale(
+ OUStringToOString( rLanguageTag.getLanguage(), RTL_TEXTENCODING_ASCII_US).getStr(),
+ OUStringToOString( rLanguageTag.getCountry(), RTL_TEXTENCODING_ASCII_US).getStr(),
+ OUStringToOString( rVariant, RTL_TEXTENCODING_ASCII_US).getStr());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/i18nlangtag/languagetagicu.hxx b/include/i18nlangtag/languagetagicu.hxx
index 20e5349f7875..2fc9db323fe3 100644
--- a/include/i18nlangtag/languagetagicu.hxx
+++ b/include/i18nlangtag/languagetagicu.hxx
@@ -12,6 +12,7 @@
#include <sal/config.h>
#include <i18nlangtag/i18nlangtagdllapi.h>
+#include <rtl/ustring.hxx>
#include <unicode/locid.h>
class LanguageTag;
@@ -37,6 +38,17 @@ public:
Always resolves an empty tag to the system locale.
*/
static icu::Locale getIcuLocale( const LanguageTag & rLanguageTag );
+
+ /** Obtain language tag as ICU icu::Locale, adding variant data.
+
+ From the LanguageTag only language and country are used to construct
+ the icu:Locale, the variant field is copied from rVariant. For example
+ needed to create an icu::Collator instance where the variant field
+ denotes the algorithm to be used.
+
+ Always resolves an empty tag to the system locale.
+ */
+ static icu::Locale getIcuLocale( const LanguageTag & rLanguageTag, const OUString & rVariant );
};
#endif // INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX