summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-12-06 14:59:23 +0100
committerEike Rathke <erack@redhat.com>2017-12-06 15:00:25 +0100
commit6a8fc4ee51bedc40d4e39690bc65eb4c2e8a0074 (patch)
treec1d361ebf07e1a9f6c4058fc21b86a925c5f1179
parent1c41d4e229deb5ae9d5d06df6c8d2585619bc102 (diff)
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
-rw-r--r--sfx2/source/appl/sfxhelp.cxx24
1 files changed, 11 insertions, 13 deletions
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;
}
}
}