Kaydet (Commit) 4806df61 authored tarafından Eike Rathke's avatar Eike Rathke

added LanguageTagIcu::getIcuLocale() with additional variant

Change-Id: I5a5689f449ac7653bb716f2ce67ea1039fe2559c
üst 3ca2240e
......@@ -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: */
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment