[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - xmlhelp/source
Eike Rathke (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jun 28 16:03:35 UTC 2019
xmlhelp/source/cxxhelp/provider/databases.cxx | 30 ++++++++++----------------
xmlhelp/source/cxxhelp/provider/databases.hxx | 9 -------
2 files changed, 13 insertions(+), 26 deletions(-)
New commits:
commit 393bfc06fd5a805657296fb36fefd2197b88555c
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Fri Jun 28 16:03:23 2019 +0200
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Fri Jun 28 18:02:58 2019 +0200
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 at redhat.com>
Tested-by: Jenkins
(cherry picked from commit 41cf4e6604bfb9b51ce54c5ea64d77249c7545d7)
Reviewed-on: https://gerrit.libreoffice.org/74849
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index e12ae7930853..bf73b4586a01 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]; }
More information about the Libreoffice-commits
mailing list