Fix Help collator loading, processLang() does not return only the language
... but a tag of an installed language, e.g. "en-US".
Adding a country then resulted in "en-US-US", used to load a
collator.
Further inspection of processLang() needed which can't work for
sr-Latn or ca-valencia, for example.
Change-Id: Id587ede738143c506da1ff2822aa605d0e7bee83
Reviewed-on: https://gerrit.libreoffice.org/74847
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index 26b6739..9f75248 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -408,6 +408,8 @@ OUString Databases::processLang( const OUString& Language )
ret = Language;
m_aLangSet[ Language ] = ret;
}
/* FIXME-BCP47: this is wrong, does not work as soon as script or
* variant is involved in the language tag. */
else if( ( ( idx = Language.indexOf( '-' ) ) != -1 ||
( idx = Language.indexOf( '_' ) ) != -1 ) &&
osl::FileBase::E_None == osl::DirectoryItem::get( getInstallPathAsURL() + Language.copy( 0,idx ),
@@ -423,16 +425,6 @@ OUString Databases::processLang( const OUString& Language )
return ret;
}
OUString Databases::country( const OUString& Language )
{
sal_Int32 idx;
if( ( idx = Language.indexOf( '-' ) ) != -1 ||
( idx = Language.indexOf( '_' ) ) != -1 )
return Language.copy( 1+idx );
return OUString();
}
helpdatafileproxy::Hdf* Databases::getHelpDataFile( const OUString& Database,
const OUString& Language, bool helpText,
const OUString* pExtensionPath )
@@ -495,10 +487,11 @@ Databases::getCollator( const OUString& Language )
if( ! it->second.is() )
{
it->second = Collator::create(m_xContext);
OUString langStr = processLang(Language);
OUString countryStr = country(Language);
LanguageTag aLanguageTag( Language);
OUString countryStr = aLanguageTag.getCountry();
if( countryStr.isEmpty() )
{
const OUString langStr = aLanguageTag.getLanguage();
if( langStr == "de" )
countryStr = "DE";
else if( langStr == "en" )
@@ -515,13 +508,14 @@ Databases::getCollator( const OUString& Language )
countryStr = "JP";
else if( langStr == "ko" )
countryStr = "KR";
// XXX NOTE: there are no complex language tags involved in those
// "add country" cases, only because of this we can use this
// simplified construction.
if (!countryStr.isEmpty())
aLanguageTag.reset( langStr + "-" + countryStr);
}
/* FIXME-BCP47: all this does not look right for language tag context,
* also check processLang() and country() methods */
it->second->loadDefaultCollator( Locale( langStr,
countryStr,
OUString() ),
0 );
it->second->loadDefaultCollator( aLanguageTag.getLocale(), 0);
}
return it->second;
diff --git a/xmlhelp/source/cxxhelp/provider/databases.hxx b/xmlhelp/source/cxxhelp/provider/databases.hxx
index 3900e99..c7ffa76 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.hxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.hxx
@@ -204,18 +204,11 @@ namespace chelp {
OUString* o_pExtensionRegistryPath = nullptr );
/**
* Maps a given language-locale combination to language.
* Maps a given language-locale combination to language or locale.
*/
OUString processLang( const OUString& Language );
/**
* Maps a given language-locale combination to locale.
* The returned string maybe empty
*/
static OUString country( const OUString& Language );
void replaceName( OUString& oustring ) const;
const OUString& getProductName() const { return m_vReplacement[0]; }