added getVariants()

Change-Id: Ib5a880698dd6faea9a5b592221f2b302889bfc24
This commit is contained in:
Eike Rathke 2013-08-28 16:10:18 +02:00
parent 923d4435cc
commit 4875278bfb
2 changed files with 42 additions and 0 deletions

View file

@ -842,6 +842,31 @@ OUString LanguageTag::getRegionFromLangtag()
}
OUString LanguageTag::getVariantsFromLangtag()
{
OUString aVariants;
synCanonicalize();
if (maBcp47.isEmpty())
return aVariants;
if (mpImplLangtag)
{
const lt_list_t* pVariantsT = lt_tag_get_variants( MPLANGTAG);
for (const lt_list_t* pE = pVariantsT; pE; pE = lt_list_next( pE))
{
const lt_pointer_t pV = lt_list_value( pE);
if (pV)
{
if (aVariants.isEmpty())
aVariants = OUString::createFromAscii( static_cast<const char*>(pV));
else
aVariants += "-" + OUString::createFromAscii( static_cast<const char*>(pV));
}
}
}
return aVariants;
}
const com::sun::star::lang::Locale & LanguageTag::getLocale( bool bResolveSystem ) const
{
if (!bResolveSystem && mbSystemLocale)
@ -1016,6 +1041,12 @@ OUString LanguageTag::getRegion() const
}
OUString LanguageTag::getVariants() const
{
return const_cast<LanguageTag*>(this)->getVariantsFromLangtag();
}
OUString LanguageTag::getGlibcLocaleString( const OUString & rEncoding ) const
{
OUString aRet;

View file

@ -184,6 +184,16 @@ public:
*/
OUString getRegion() const;
/** Get BCP 47 variant subtags, of the IANA Language Subtag Registry.
If there are multiple variant subtags they are separated by '-'.
This is NOT related to Locale.Variant!
Always resolves an empty tag to the system locale.
*/
OUString getVariants() const;
/** Get a GLIBC locale string.
Always resolves an empty tag to the system locale.
@ -483,6 +493,7 @@ private:
OUString getLanguageFromLangtag();
OUString getScriptFromLangtag();
OUString getRegionFromLangtag();
OUString getVariantsFromLangtag();
void resetVars();