xmlhelp/source/cxxhelp/provider/databases.cxx | 30 ++++++++++---------------- xmlhelp/source/cxxhelp/provider/databases.hxx | 9 ------- 2 files changed, 13 insertions(+), 26 deletions(-)
New commits: commit 41cf4e6604bfb9b51ce54c5ea64d77249c7545d7 Author: Eike Rathke <er...@redhat.com> AuthorDate: Fri Jun 28 16:03:23 2019 +0200 Commit: Eike Rathke <er...@redhat.com> CommitDate: Fri Jun 28 17:01:28 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 <er...@redhat.com> Tested-by: Jenkins 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]; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits