getFallbackStrings() with bIncludeFullBcp47 parameter
so the various places that check the full tag first do not have to get it just to delete it again. Change-Id: Ib4e3cf1b16988464db875f1b6ac5cf4a0ab60fe5
This commit is contained in:
@@ -728,12 +728,9 @@ DescriptionInfoset::getLocalizedChild( const OUString & sParent) const
|
||||
//office: en-DE, en, en-DE-altmark
|
||||
if (! nodeMatch.is())
|
||||
{
|
||||
const ::std::vector< OUString > aFallbacks = getOfficeLanguageTag().getFallbackStrings();
|
||||
// Already tried full tag, continue with first fallback.
|
||||
::std::vector< OUString >::const_iterator it( aFallbacks.begin());
|
||||
if (it != aFallbacks.end())
|
||||
++it;
|
||||
for ( ; it != aFallbacks.end(); ++it)
|
||||
const ::std::vector< OUString > aFallbacks( getOfficeLanguageTag().getFallbackStrings( false));
|
||||
for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it)
|
||||
{
|
||||
nodeMatch = matchLanguageTag(xParent, *it);
|
||||
if (nodeMatch.is())
|
||||
|
@@ -1420,7 +1420,7 @@ void BackendImpl::PackageImpl::scanBundle(
|
||||
|
||||
|
||||
const LanguageTag& officeLocale = getOfficeLanguageTag();
|
||||
const ::std::vector< OUString > officeFallbacks( officeLocale.getFallbackStrings());
|
||||
const ::std::vector< OUString > officeFallbacks( officeLocale.getFallbackStrings( true));
|
||||
const size_t nPenaltyMax = ::std::numeric_limits<size_t>::max();
|
||||
size_t descrPenalty = nPenaltyMax;
|
||||
OUString descrFile;
|
||||
@@ -1475,7 +1475,7 @@ void BackendImpl::PackageImpl::scanBundle(
|
||||
if (officeLocale.getLanguage() == descrTag.getLanguage())
|
||||
{
|
||||
size_t nPenalty = nPenaltyMax;
|
||||
const ::std::vector< OUString > descrFallbacks( descrTag.getFallbackStrings());
|
||||
const ::std::vector< OUString > descrFallbacks( descrTag.getFallbackStrings( true));
|
||||
for (size_t o=0; o < officeFallbacks.size() && nPenalty == nPenaltyMax; ++o)
|
||||
{
|
||||
for (size_t d=0; d < descrFallbacks.size() && nPenalty == nPenaltyMax; ++d)
|
||||
|
@@ -161,7 +161,7 @@ void TestLanguageTag::testAllTags()
|
||||
CPPUNIT_ASSERT( ca_ES_valencia.getCountry() == "ES" );
|
||||
CPPUNIT_ASSERT( ca_ES_valencia.getScript() == "" );
|
||||
CPPUNIT_ASSERT( ca_ES_valencia.getLanguageAndScript() == "ca" );
|
||||
::std::vector< OUString > ca_ES_valencia_Fallbacks( ca_ES_valencia.getFallbackStrings());
|
||||
::std::vector< OUString > ca_ES_valencia_Fallbacks( ca_ES_valencia.getFallbackStrings( true));
|
||||
CPPUNIT_ASSERT( ca_ES_valencia_Fallbacks.size() == 4);
|
||||
CPPUNIT_ASSERT( ca_ES_valencia_Fallbacks[0] == "ca-ES-valencia");
|
||||
CPPUNIT_ASSERT( ca_ES_valencia_Fallbacks[1] == "ca-valencia");
|
||||
@@ -186,7 +186,7 @@ void TestLanguageTag::testAllTags()
|
||||
CPPUNIT_ASSERT( ca_valencia.getCountry() == "" );
|
||||
CPPUNIT_ASSERT( ca_valencia.getScript() == "" );
|
||||
CPPUNIT_ASSERT( ca_valencia.getLanguageAndScript() == "ca" );
|
||||
::std::vector< OUString > ca_valencia_Fallbacks( ca_valencia.getFallbackStrings());
|
||||
::std::vector< OUString > ca_valencia_Fallbacks( ca_valencia.getFallbackStrings( true));
|
||||
CPPUNIT_ASSERT( ca_valencia_Fallbacks.size() == 2);
|
||||
CPPUNIT_ASSERT( ca_valencia_Fallbacks[0] == "ca-valencia");
|
||||
CPPUNIT_ASSERT( ca_valencia_Fallbacks[1] == "ca");
|
||||
|
@@ -74,7 +74,7 @@ static const KnownTagSet & getKnowns()
|
||||
// Do not use the BCP47 string here to initialize the
|
||||
// LanguageTag because then canonicalize() would call this
|
||||
// getKnowns() again..
|
||||
::std::vector< OUString > aFallbacks( LanguageTag( (*it).mnLang).getFallbackStrings());
|
||||
::std::vector< OUString > aFallbacks( LanguageTag( (*it).mnLang).getFallbackStrings( true));
|
||||
for (::std::vector< OUString >::const_iterator fb( aFallbacks.begin()); fb != aFallbacks.end(); ++fb)
|
||||
{
|
||||
rKnowns.insert( *fb);
|
||||
@@ -1198,8 +1198,7 @@ LanguageTag & LanguageTag::makeFallback()
|
||||
{
|
||||
// "en-US" is the last resort fallback, try if we get a better
|
||||
// one for the fallback hierarchy of a non-"en" locale.
|
||||
::std::vector< OUString > aFallbacks( getFallbackStrings());
|
||||
aFallbacks.erase( aFallbacks.begin()); // first is full BCP47, we already checked that
|
||||
::std::vector< OUString > aFallbacks( getFallbackStrings( false));
|
||||
for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it)
|
||||
{
|
||||
lang::Locale aLocale3( LanguageTag( *it).getLocale());
|
||||
@@ -1219,7 +1218,7 @@ LanguageTag & LanguageTag::makeFallback()
|
||||
}
|
||||
|
||||
|
||||
::std::vector< OUString > LanguageTag::getFallbackStrings() const
|
||||
::std::vector< OUString > LanguageTag::getFallbackStrings( bool bIncludeFullBcp47 ) const
|
||||
{
|
||||
::std::vector< OUString > aVec;
|
||||
OUString aLanguage( getLanguage());
|
||||
@@ -1228,7 +1227,8 @@ LanguageTag & LanguageTag::makeFallback()
|
||||
{
|
||||
if (!aCountry.isEmpty())
|
||||
{
|
||||
aVec.push_back( aLanguage + "-" + aCountry);
|
||||
if (bIncludeFullBcp47)
|
||||
aVec.push_back( aLanguage + "-" + aCountry);
|
||||
if (aLanguage == "zh")
|
||||
{
|
||||
// For zh-HK or zh-MO also list zh-TW, for all other zh-XX also
|
||||
@@ -1239,10 +1239,13 @@ LanguageTag & LanguageTag::makeFallback()
|
||||
aVec.push_back( aLanguage + "-CN");
|
||||
}
|
||||
}
|
||||
aVec.push_back( aLanguage);
|
||||
else if (bIncludeFullBcp47)
|
||||
aVec.push_back( aLanguage);
|
||||
return aVec;
|
||||
}
|
||||
aVec.push_back( getBcp47());
|
||||
|
||||
if (bIncludeFullBcp47)
|
||||
aVec.push_back( getBcp47());
|
||||
OUString aVariants( getVariants());
|
||||
OUString aTmp;
|
||||
if (hasScript())
|
||||
@@ -1471,8 +1474,7 @@ LanguageTag::Extraction LanguageTag::simpleExtract( const OUString& rBcp47,
|
||||
return it; // exact match
|
||||
}
|
||||
|
||||
::std::vector< OUString > aFallbacks( LanguageTag( rReference).getFallbackStrings());
|
||||
aFallbacks.erase( aFallbacks.begin()); // first is full BCP47, we already checked that
|
||||
::std::vector< OUString > aFallbacks( LanguageTag( rReference).getFallbackStrings( false));
|
||||
if (rReference != "en-US")
|
||||
{
|
||||
aFallbacks.push_back( "en-US");
|
||||
@@ -1524,13 +1526,12 @@ LanguageTag::Extraction LanguageTag::simpleExtract( const OUString& rBcp47,
|
||||
}
|
||||
|
||||
// Now for each reference fallback test the fallbacks of the list in order.
|
||||
::std::vector< OUString > aFallbacks( LanguageTag( rReference).getFallbackStrings());
|
||||
aFallbacks.erase( aFallbacks.begin()); // first is full BCP47, we already checked that
|
||||
::std::vector< OUString > aFallbacks( LanguageTag( rReference).getFallbackStrings( false));
|
||||
::std::vector< ::std::vector< OUString > > aListFallbacks( rList.size());
|
||||
size_t i = 0;
|
||||
for (it = rList.begin(); it != rList.end(); ++it, ++i)
|
||||
{
|
||||
::std::vector< OUString > aTmp( LanguageTag( *it).getFallbackStrings());
|
||||
::std::vector< OUString > aTmp( LanguageTag( *it).getFallbackStrings( true));
|
||||
aListFallbacks[i] = aTmp;
|
||||
}
|
||||
for (::std::vector< OUString >::const_iterator rfb( aFallbacks.begin()); rfb != aFallbacks.end(); ++rfb)
|
||||
|
@@ -1649,8 +1649,7 @@ OUString LocaleDataImpl::getFirstLocaleServiceName( const com::sun::star::lang::
|
||||
::std::vector< OUString > aVec;
|
||||
if (rLocale.Language == I18NLANGTAG_QLT)
|
||||
{
|
||||
aVec = LanguageTag( rLocale).getFallbackStrings();
|
||||
aVec.erase( aVec.begin());
|
||||
aVec = LanguageTag( rLocale).getFallbackStrings( false);
|
||||
for (::std::vector< OUString >::iterator it(aVec.begin()); it != aVec.end(); ++it)
|
||||
{
|
||||
*it = (*it).replace( cHyphen, cUnder);
|
||||
|
@@ -267,6 +267,17 @@ public:
|
||||
lll-CC
|
||||
lll
|
||||
|
||||
If the tag includes variants the order is:
|
||||
full BCP 47 tag, same as getBcp47()
|
||||
lll-Ssss-CC-vvvvvvvv
|
||||
lll-Ssss-vvvvvvvv
|
||||
lll-Ssss-CC
|
||||
lll-Ssss
|
||||
lll-CC-vvvvvvvv
|
||||
lll-vvvvvvvv
|
||||
lll-CC
|
||||
lll
|
||||
|
||||
Only strings that differ from a higher order are included, for example
|
||||
if there is no script the elements will be bcp47, lll-CC, lll; if the
|
||||
bcp47 string is identical to lll-CC then only lll-CC, lll.
|
||||
@@ -274,8 +285,14 @@ public:
|
||||
Note that lll is only ISO 639-1/2 alpha code and CC is only ISO 3166
|
||||
alpha code. If the region can not be expressed as ISO 3166 then no -CC
|
||||
tags are included.
|
||||
|
||||
@param bIncludeFullBcp47
|
||||
If TRUE, the full BCP 47 tag is included as first element.
|
||||
If FALSE, the full tag is not included; used if the caller
|
||||
obtains the fallbacks only if the full tag did not lead to a
|
||||
match, so subsequent tries need not to include it again.
|
||||
*/
|
||||
::std::vector< OUString > getFallbackStrings() const;
|
||||
::std::vector< OUString > getFallbackStrings( bool bIncludeFullBcp47 ) const;
|
||||
|
||||
|
||||
/** @short Search for an equal or at least for a similar locale in a list
|
||||
|
@@ -82,7 +82,7 @@ OString RscTypCont::ChangeLanguage(const OString& rNewLang)
|
||||
if (rNewLang.isEmpty())
|
||||
aFallbacks.push_back( "" ); // do not resolve to SYSTEM (en-US)
|
||||
else
|
||||
aFallbacks = LanguageTag( OStringToOUString( rNewLang, RTL_TEXTENCODING_ASCII_US)).getFallbackStrings();
|
||||
aFallbacks = LanguageTag( OStringToOUString( rNewLang, RTL_TEXTENCODING_ASCII_US)).getFallbackStrings( true);
|
||||
|
||||
bool bAppendEnUsFallback = ! (rNewLang.equalsIgnoreAsciiCase( "en-US" ) ||
|
||||
rNewLang.equalsIgnoreAsciiCase( "x-no-translate" ) );
|
||||
|
@@ -93,7 +93,7 @@ void RscLangEnum::Init( RscNameTable& rNames )
|
||||
fprintf( stderr, "ISO Language out:");
|
||||
#endif
|
||||
LanguageTag aLanguageTag( (*iTag).maBcp47);
|
||||
::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings());
|
||||
::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings( true));
|
||||
for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it)
|
||||
{
|
||||
OString aLang( OUStringToOString( *it, RTL_TEXTENCODING_ASCII_US));
|
||||
|
@@ -156,7 +156,7 @@ bool ScUnoAddInFuncData::GetExcelName( LanguageType eDestLang, OUString& rRetExc
|
||||
|
||||
// Second, try match of fallback search with fallback locales,
|
||||
// appending also 'en-US' and 'en' to search if not queried.
|
||||
::std::vector< OUString > aFallbackSearch( aLanguageTag.getFallbackStrings());
|
||||
::std::vector< OUString > aFallbackSearch( aLanguageTag.getFallbackStrings( true));
|
||||
if (aSearch != "en-US")
|
||||
{
|
||||
aFallbackSearch.push_back( "en-US");
|
||||
@@ -165,22 +165,16 @@ bool ScUnoAddInFuncData::GetExcelName( LanguageType eDestLang, OUString& rRetExc
|
||||
aFallbackSearch.push_back( "en");
|
||||
}
|
||||
}
|
||||
bool bFirst = true;
|
||||
::std::vector< OUString >::const_iterator itSearch( aFallbackSearch.begin());
|
||||
for ( ; itSearch != aFallbackSearch.end(); ++itSearch)
|
||||
{
|
||||
itNames = rCompNames.begin();
|
||||
for ( ; itNames != rCompNames.end(); ++itNames)
|
||||
{
|
||||
::std::vector< OUString > aFallbackLocales( LanguageTag( (*itNames).maLocale).getFallbackStrings());
|
||||
::std::vector< OUString >::const_iterator itLocales( aFallbackLocales.begin());
|
||||
if (bFirst)
|
||||
{
|
||||
// We checked already the full tag, start with second.
|
||||
if (itLocales != aFallbackLocales.end())
|
||||
++itLocales;
|
||||
}
|
||||
for ( ; itLocales != aFallbackLocales.end(); ++itLocales)
|
||||
// We checked already the full tag, start with second.
|
||||
::std::vector< OUString > aFallbackLocales( LanguageTag( (*itNames).maLocale).getFallbackStrings( false));
|
||||
for (::std::vector< OUString >::const_iterator itLocales( aFallbackLocales.begin());
|
||||
itLocales != aFallbackLocales.end(); ++itLocales)
|
||||
{
|
||||
if (*itLocales == *itSearch)
|
||||
{
|
||||
@@ -189,7 +183,6 @@ bool ScUnoAddInFuncData::GetExcelName( LanguageType eDestLang, OUString& rRetExc
|
||||
}
|
||||
}
|
||||
}
|
||||
bFirst = false;
|
||||
}
|
||||
|
||||
// Third, last resort, use first (default) entry.
|
||||
|
@@ -31,7 +31,7 @@ OUString GalleryThemeEntry::ReadStrFromIni(const OUString &aKeyName )
|
||||
|
||||
const LanguageTag &rLangTag = Application::GetSettings().GetUILanguageTag();
|
||||
|
||||
::std::vector< OUString > aFallbacks = rLangTag.getFallbackStrings();
|
||||
::std::vector< OUString > aFallbacks = rLangTag.getFallbackStrings( true);
|
||||
|
||||
OUString aResult;
|
||||
sal_Int32 nRank = 42;
|
||||
@@ -71,6 +71,7 @@ OUString GalleryThemeEntry::ReadStrFromIni(const OUString &aKeyName )
|
||||
// grisly language matching, is this not available somewhere else?
|
||||
if( aKey == aKeyName )
|
||||
{
|
||||
/* FIXME-BCP47: what is this supposed to do? */
|
||||
n = 0;
|
||||
OUString aLang = aLocale.replace('_','-');
|
||||
for( std::vector< OUString >::const_iterator i = aFallbacks.begin();
|
||||
|
@@ -233,7 +233,7 @@ InternalResMgr* ResMgrContainer::getResMgr( const OUString& rPrefix,
|
||||
LanguageTag aLocale( rLocale );
|
||||
boost::unordered_map< OUString, ContainerElement, OUStringHash >::iterator it = m_aResFiles.end();
|
||||
|
||||
::std::vector< OUString > aFallbacks( aLocale.getFallbackStrings());
|
||||
::std::vector< OUString > aFallbacks( aLocale.getFallbackStrings( true));
|
||||
if (!isAlreadyPureenUS( aLocale))
|
||||
aFallbacks.push_back( "en-US"); // last resort if all fallbacks fail
|
||||
|
||||
@@ -356,7 +356,7 @@ InternalResMgr* ResMgrContainer::getNextFallback( InternalResMgr* pMgr )
|
||||
* passed / remember a fallback list and an index within to pick the next.
|
||||
* */
|
||||
|
||||
::std::vector< OUString > aFallbacks( pMgr->aLocale.getFallbackStrings());
|
||||
::std::vector< OUString > aFallbacks( pMgr->aLocale.getFallbackStrings( true));
|
||||
// The first is the locale itself, use next fallback or en-US.
|
||||
/* TODO: what happens if the chain is "en-US", "en" -> "en-US", ...
|
||||
* This was already an issue with the previous code. */
|
||||
|
@@ -225,8 +225,7 @@ OUString DefaultFontConfiguration::getDefaultFont( const LanguageTag& rLanguageT
|
||||
}
|
||||
else
|
||||
{
|
||||
::std::vector< OUString > aFallbacks( rLanguageTag.getFallbackStrings());
|
||||
aFallbacks.erase( aFallbacks.begin()); // first is full BCP47, we already checked that
|
||||
::std::vector< OUString > aFallbacks( rLanguageTag.getFallbackStrings( false));
|
||||
for (::std::vector< OUString >::const_iterator it( aFallbacks.begin());
|
||||
it != aFallbacks.end() && aRet.isEmpty(); ++it)
|
||||
{
|
||||
@@ -1147,7 +1146,7 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontN
|
||||
if( aLanguageTag.isSystemLocale() )
|
||||
aLanguageTag = SvtSysLocale().GetUILanguageTag();
|
||||
|
||||
::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings());
|
||||
::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings( true));
|
||||
if (aLanguageTag.getLanguage() != "en")
|
||||
aFallbacks.push_back("en");
|
||||
|
||||
|
@@ -60,7 +60,7 @@ bool Application::LoadBrandBitmap (const char* pName, BitmapEx &rBitmap)
|
||||
osl_getProcessLocale (&pLoc);
|
||||
LanguageTag aLanguageTag( *pLoc);
|
||||
|
||||
::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings());
|
||||
::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings( true));
|
||||
for (size_t i=0; i < aFallbacks.size(); ++i)
|
||||
{
|
||||
if (tryLoadPng( aBaseDir, aBaseName + "-" + aFallbacks[i] + aPng, rBitmap))
|
||||
|
@@ -197,7 +197,7 @@ bool ImplImageTree::doLoadImage(
|
||||
sal_Int32 pos = name.lastIndexOf('/');
|
||||
if (pos != -1) {
|
||||
// find() uses a reverse iterator, so push in reverse order.
|
||||
std::vector< OUString > aFallbacks( Application::GetSettings().GetUILanguageTag().getFallbackStrings());
|
||||
std::vector< OUString > aFallbacks( Application::GetSettings().GetUILanguageTag().getFallbackStrings( true));
|
||||
for (std::vector< OUString >::const_reverse_iterator it( aFallbacks.rbegin());
|
||||
it != aFallbacks.rend(); ++it)
|
||||
{
|
||||
|
Reference in New Issue
Block a user