From 219aae1cea7ba88d5a4503f8070566755efd3aef Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 28 Sep 2016 10:26:00 +0100 Subject: 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 --- desktop/source/app/langselect.cxx | 47 +++++---------------------------------- 1 file changed, 5 insertions(+), 42 deletions(-) (limited to 'desktop/source/app/langselect.cxx') 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 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 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; -- cgit