summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-09-28 10:26:00 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-09-28 11:39:00 +0100
commit219aae1cea7ba88d5a4503f8070566755efd3aef (patch)
tree5220ac449756a14d31edeb81118a62e88d604dae /svl
parent0145d83cc7872bf943de12e386645a7aa8868f5d (diff)
Resolves: tdf#96748 'Default Language' show current ui lang not new default
i.e. if you select it, then the General::UILocale is unset and a new default generated based on the L10N::UILocale and what langpacks are installed but what the entry string claims is "Default - Current Language", rather than "Default - The Language That Will Be Used", so split out the language selection code into a reusable bit and use that to get the name of the language which will be selected if this entry is used Change-Id: I13d901c9a47ef213aea86417501114d4231efae5
Diffstat (limited to 'svl')
-rw-r--r--svl/source/config/languageoptions.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/svl/source/config/languageoptions.cxx b/svl/source/config/languageoptions.cxx
index 92cbd67d3992..bee71bb4534e 100644
--- a/svl/source/config/languageoptions.cxx
+++ b/svl/source/config/languageoptions.cxx
@@ -27,6 +27,7 @@
#include <rtl/instance.hxx>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <unotools/syslocale.hxx>
+#include "officecfg/System.hxx"
#ifdef _WIN32
#include <windows.h>
@@ -264,4 +265,35 @@ bool SvtSystemLanguageOptions::isCJKKeyboardLayoutInstalled() const
return isKeyboardLayoutTypeInstalled(css::i18n::ScriptType::ASIAN);
}
+OUString getInstalledLocaleForLanguage(css::uno::Sequence<OUString> const & installed, OUString const & locale)
+{
+ if (locale.isEmpty())
+ return OUString(); // do not attempt to resolve anything
+
+ for (sal_Int32 i = 0; i != installed.getLength(); ++i) {
+ if (installed[i] == locale) {
+ return installed[i];
+ }
+ }
+ std::vector<OUString> fallbacks(LanguageTag(locale).getFallbackStrings(false));
+ for (OUString & rf : fallbacks) {
+ for (sal_Int32 i = 0; i != installed.getLength(); ++i) {
+ if (installed[i] == rf) {
+ return installed[i];
+ }
+ }
+ }
+ return OUString();
+}
+
+OUString getInstalledLocaleForSystemUILanguage(const css::uno::Sequence<OUString>& rLocaleElementNames)
+{
+ OUString locale = getInstalledLocaleForLanguage(rLocaleElementNames, officecfg::System::L10N::UILocale::get());
+ if (locale.isEmpty())
+ locale = getInstalledLocaleForLanguage(rLocaleElementNames, "en-US");
+ if (locale.isEmpty() && rLocaleElementNames.hasElements())
+ locale = rLocaleElementNames[0];
+ return locale;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */