summaryrefslogtreecommitdiff
path: root/desktop
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 /desktop
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 'desktop')
-rw-r--r--desktop/source/app/langselect.cxx47
1 files changed, 5 insertions, 42 deletions
diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx
index a8309e5987ba..9b52d8a42fe9 100644
--- a/desktop/source/app/langselect.cxx
+++ b/desktop/source/app/langselect.cxx
@@ -49,28 +49,6 @@ namespace {
OUString foundLocale;
-OUString getInstalledLocale(
- 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();
-}
-
void setMsLangIdFallback(OUString const & locale) {
// #i32939# setting of default document language
// See #i42730# for rules for determining source of settings
@@ -101,24 +79,16 @@ OUString getEmergencyLocale() {
officecfg::Setup::Office::InstalledLocales::get()->
getElementNames());
OUString locale(
- getInstalledLocale(
+ getInstalledLocaleForLanguage(
inst,
officecfg::Office::Linguistic::General::UILocale::get()));
if (!locale.isEmpty()) {
return locale;
}
- locale = getInstalledLocale(
- inst, officecfg::System::L10N::UILocale::get());
- if (!locale.isEmpty()) {
- return locale;
- }
- locale = getInstalledLocale(inst, "en-US");
+ locale = getInstalledLocaleForSystemUILanguage(inst);
if (!locale.isEmpty()) {
return locale;
}
- if (inst.hasElements()) {
- return inst[0];
- }
} catch (css::uno::Exception & e) {
SAL_WARN("desktop.app", "ignoring Exception \"" << e.Message << "\"");
}
@@ -135,7 +105,7 @@ bool prepareLocale() {
officecfg::Setup::Office::InstalledLocales::get()->getElementNames());
OUString locale(officecfg::Office::Linguistic::General::UILocale::get());
if (!locale.isEmpty()) {
- locale = getInstalledLocale(inst, locale);
+ locale = getInstalledLocaleForLanguage(inst, locale);
if (locale.isEmpty()) {
// Selected language is not/no longer installed:
try {
@@ -153,21 +123,14 @@ bool prepareLocale() {
}
bool cmdLanguage = false;
if (locale.isEmpty()) {
- locale = getInstalledLocale(
+ locale = getInstalledLocaleForLanguage(
inst, Desktop::GetCommandLineArgs().GetLanguage());
if (!locale.isEmpty()) {
cmdLanguage = true;
}
}
if (locale.isEmpty()) {
- locale = getInstalledLocale(
- inst, officecfg::System::L10N::UILocale::get());
- }
- if (locale.isEmpty()) {
- locale = getInstalledLocale(inst, "en-US");
- }
- if (locale.isEmpty() && inst.hasElements()) {
- locale = inst[0];
+ locale = getInstalledLocaleForSystemUILanguage(inst);
}
if (locale.isEmpty()) {
return false;