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

use LanguageTag::getMatchingFallback()

Change-Id: Ib6fd9581728bdd7c32ccec9ce538d9b4c5658b04
üst 00de85cc
......@@ -25,6 +25,7 @@ $(eval $(call gb_Library_use_libraries,stringresource,\
cppuhelper \
sal \
tl \
i18nlangtag \
$(gb_UWINAPI) \
))
......
......@@ -36,6 +36,7 @@
#include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx>
#include <tools/urlobj.hxx>
#include <i18nlangtag/languagetag.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
......@@ -679,33 +680,21 @@ LocaleItem* StringResourceImpl::getItemForLocale
return pRetItem;
}
// Returns the LocalItem for a given locale, if it exists, otherwise NULL
// This method performes a closest match search, at least the language must match
// Returns the LocaleItem for a given locale, if it exists, otherwise NULL.
// This method performs a closest match search, at least the language must match.
LocaleItem* StringResourceImpl::getClosestMatchItemForLocale( const Locale& locale )
{
LocaleItem* pRetItem = NULL;
// Search for locale
for( sal_Int32 iPass = 0 ; iPass <= 2 ; ++iPass )
::std::vector< Locale > aLocales( m_aLocaleItemVector.size());
for( LocaleItemVectorConstIt it = m_aLocaleItemVector.begin(); it != m_aLocaleItemVector.end(); ++it )
{
for( LocaleItemVectorConstIt it = m_aLocaleItemVector.begin(); it != m_aLocaleItemVector.end(); ++it )
{
LocaleItem* pLocaleItem = *it;
if( pLocaleItem )
{
Locale& cmp_locale = pLocaleItem->m_locale;
if( cmp_locale.Language == locale.Language &&
(iPass > 1 || cmp_locale.Country == locale.Country) &&
(iPass > 0 || cmp_locale.Variant == locale.Variant) )
{
pRetItem = pLocaleItem;
break;
}
}
}
if( pRetItem )
break;
LocaleItem* pLocaleItem = *it;
aLocales.push_back( pLocaleItem ? pLocaleItem->m_locale : Locale());
}
::std::vector< Locale >::const_iterator iFound( LanguageTag::getMatchingFallback( aLocales, locale));
if (iFound != aLocales.end())
pRetItem = *(m_aLocaleItemVector.begin() + (iFound - aLocales.begin()));
return pRetItem;
}
......
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