Kaydet (Commit) 6a8fc4ee authored tarafından Eike Rathke's avatar Eike Rathke

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
üst 1c41d4e2
......@@ -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;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment