sfx2/source/appl/sfxhelp.cxx | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-)
New commits: commit 6a8fc4ee51bedc40d4e39690bc65eb4c2e8a0074 Author: Eike Rathke <er...@redhat.com> Date: Wed Dec 6 14:59:23 2017 +0100 Use proper language fallback chain to find installed help The previous code first tried the full tag and if not successful a tag up to the first hyphen, which so far was the same as the fallback chain but may differ for more sophisticated language tags in the future. Change-Id: I01dd8618c77c30e92a5fef6d01d0da56f70353f1 diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx index 2df8b5ac7012..af38b75182cb 100644 --- a/sfx2/source/appl/sfxhelp.cxx +++ b/sfx2/source/appl/sfxhelp.cxx @@ -102,7 +102,7 @@ static OUString const & HelpLocaleString() if (aLocaleStr.isEmpty()) { const OUString aEnglish( "en" ); - // detect installed locale + // obtain selected UI language (/org.openoffice.Setup/L10N/ooLocale) aLocaleStr = utl::ConfigManager::getLocale(); bool bOk = !aLocaleStr.isEmpty(); if ( !bOk ) @@ -113,21 +113,19 @@ static OUString const & HelpLocaleString() utl::Bootstrap::locateBaseInstallation(aBaseInstallPath); static const char szHelpPath[] = "/help/"; - OUString sHelpPath = aBaseInstallPath + szHelpPath + aLocaleStr; - osl::DirectoryItem aDirItem; - - if (osl::DirectoryItem::get(sHelpPath, aDirItem) != osl::FileBase::E_None) + // Use a fallback chain starting from full tag, which here usually + // is only the language hence only one value, but can also be en-US + // or ca-valencia or include script tags. + std::vector< OUString > aFallbacks( LanguageTag( aLocaleStr).getFallbackStrings( true)); + for (auto const& rTag : aFallbacks) { - bOk = false; - OUString sLang(aLocaleStr); - sal_Int32 nSepPos = sLang.indexOf( '-' ); - if (nSepPos != -1) + OUString sHelpPath( aBaseInstallPath + szHelpPath + rTag); + osl::DirectoryItem aDirItem; + if (osl::DirectoryItem::get(sHelpPath, aDirItem) == osl::FileBase::E_None) { + aLocaleStr = rTag; bOk = true; - sLang = sLang.copy( 0, nSepPos ); - sHelpPath = aBaseInstallPath + szHelpPath + sLang; - if (osl::DirectoryItem::get(sHelpPath, aDirItem) != osl::FileBase::E_None) - bOk = false; + break; } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits