Kaydet (Commit) 555d88d0 authored tarafından Eike Rathke's avatar Eike Rathke

added reset(rtl_Locale)

Change-Id: I1bc83dd4e5286f7102513d8a4c7d5624952eb830
üst 2c36a832
......@@ -205,6 +205,9 @@ public:
/** Reset with LanguageType MS-LangID. */
void reset( LanguageType nLanguage );
/** Reset with rtl_Locale. */
void reset( const rtl_Locale & rLocale );
/** Fall back to a known locale.
......@@ -275,6 +278,8 @@ private:
void convertLangToLocale();
void convertLangToBcp47();
void convertFromRtlLocale();
bool canonicalize();
rtl::OUString getLanguageFromLangtag();
......
......@@ -248,41 +248,7 @@ LanguageTag::LanguageTag( const rtl_Locale & rLocale )
mbCachedCountry( false),
mbIsFallback( false)
{
// The rtl_Locale follows the Open Group Base Specification,
// 8.2 Internationalization Variables
// language[_territory][.codeset][@modifier]
// On GNU/Linux systems usually being glibc locales.
// sal/osl/unx/nlsupport.c _parse_locale() parses them into
// Language: language 2 or 3 alpha code
// Country: [territory] 2 alpha code
// Variant: [.codeset][@modifier]
// Variant effectively contains anything that follows the territory, not
// looking for '.' dot delimiter or '@' modifier content.
if (!maLocale.Variant.isEmpty())
{
OString aStr = OUStringToOString( maLocale.Language + "_" + maLocale.Country + maLocale.Variant,
RTL_TEXTENCODING_UTF8);
/* FIXME: let liblangtag parse this entirely with
* lt_tag_convert_from_locale() but that needs a patch to pass the
* string. */
#if 0
myLtError aError;
theDataRef::get().incRef();
mpImplLangtag = lt_tag_convert_from_locale( aStr.getStr(), &aError.p);
maBcp47 = OStringToOUString( lt_tag_get_string( MPLANGTAG), RTL_TEXTENCODING_UTF8);
mbInitializedBcp47 = true;
#else
mnLangID = MsLangId::convertUnxByteStringToLanguage( aStr);
if (mnLangID == LANGUAGE_DONTKNOW)
{
SAL_WARN( "i18npool.langtag", "LanguageTag(rtl_Locale) - unknown: " << aStr);
mnLangID = LANGUAGE_ENGLISH_US; // we need _something_ here
}
mbInitializedLangID = true;
#endif
maLocale = lang::Locale();
mbInitializedLocale = false;
}
convertFromRtlLocale();
}
......@@ -417,6 +383,13 @@ void LanguageTag::reset( LanguageType nLanguage )
}
void LanguageTag::reset( const rtl_Locale & rLocale )
{
reset( lang::Locale( rLocale.Language, rLocale.Country, rLocale.Variant));
convertFromRtlLocale();
}
bool LanguageTag::canonicalize()
{
#ifdef erDEBUG
......@@ -671,6 +644,46 @@ void LanguageTag::convertLangToBcp47()
}
void LanguageTag::convertFromRtlLocale()
{
// The rtl_Locale follows the Open Group Base Specification,
// 8.2 Internationalization Variables
// language[_territory][.codeset][@modifier]
// On GNU/Linux systems usually being glibc locales.
// sal/osl/unx/nlsupport.c _parse_locale() parses them into
// Language: language 2 or 3 alpha code
// Country: [territory] 2 alpha code
// Variant: [.codeset][@modifier]
// Variant effectively contains anything that follows the territory, not
// looking for '.' dot delimiter or '@' modifier content.
if (!maLocale.Variant.isEmpty())
{
OString aStr = OUStringToOString( maLocale.Language + "_" + maLocale.Country + maLocale.Variant,
RTL_TEXTENCODING_UTF8);
/* FIXME: let liblangtag parse this entirely with
* lt_tag_convert_from_locale() but that needs a patch to pass the
* string. */
#if 0
myLtError aError;
theDataRef::get().incRef();
mpImplLangtag = lt_tag_convert_from_locale( aStr.getStr(), &aError.p);
maBcp47 = OStringToOUString( lt_tag_get_string( MPLANGTAG), RTL_TEXTENCODING_UTF8);
mbInitializedBcp47 = true;
#else
mnLangID = MsLangId::convertUnxByteStringToLanguage( aStr);
if (mnLangID == LANGUAGE_DONTKNOW)
{
SAL_WARN( "i18npool.langtag", "LanguageTag(rtl_Locale) - unknown: " << aStr);
mnLangID = LANGUAGE_ENGLISH_US; // we need _something_ here
}
mbInitializedLangID = true;
#endif
maLocale = lang::Locale();
mbInitializedLocale = false;
}
}
const rtl::OUString & LanguageTag::getBcp47( bool bResolveSystem ) const
{
if (!bResolveSystem && mbSystemLocale)
......
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