summaryrefslogtreecommitdiff
path: root/xmlhelp/source
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2019-06-28 16:03:23 +0200
committerEike Rathke <erack@redhat.com>2019-06-28 17:01:28 +0200
commit41cf4e6604bfb9b51ce54c5ea64d77249c7545d7 (patch)
treea90715dd35398b8bda326408b452bf6eb24f1a55 /xmlhelp/source
parent0328e0af9532d5ab26840cf58b9dcbb69bb8c33d (diff)
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
Diffstat (limited to 'xmlhelp/source')
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.cxx30
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.hxx9
2 files changed, 13 insertions, 26 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index 26b673982333..9f75248910b6 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 3900e9918cdc..c7ffa765b348 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]; }