From 7063cfa833959c925b456b32e82336cbf621ea34 Mon Sep 17 00:00:00 2001 From: Felipe Cecagno Date: Thu, 3 Sep 2015 14:04:29 -0300 Subject: [PATCH] included the "Default language" option to the list of languages --- .../locale/en_US/bbbResources.properties | 3 +- .../locale/pt_BR/bbbResources.properties | 3 +- .../bigbluebutton/util/i18n/ResourceUtil.as | 31 +++++++++++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/bigbluebutton-client/locale/en_US/bbbResources.properties b/bigbluebutton-client/locale/en_US/bbbResources.properties index 0e4b4ad4f0..cfbe801909 100755 --- a/bigbluebutton-client/locale/en_US/bbbResources.properties +++ b/bigbluebutton-client/locale/en_US/bbbResources.properties @@ -609,6 +609,7 @@ bbb.lockSettings.feature=Feature bbb.lockSettings.locked=Locked bbb.lockSettings.lockOnJoin=Lock On Join +bbb.langSelector.default=Default language bbb.langSelector.ar_SY=Arabic (Syria) bbb.langSelector.az_AZ=Azerbaijani bbb.langSelector.eu_EU=Basque @@ -658,4 +659,4 @@ bbb.langSelector.th_TH=Thai bbb.langSelector.tr_TR=Turkish bbb.langSelector.uk_UA=Ukrainian bbb.langSelector.vi_VN=Vietnamese -bbb.langSelector.cy_GB=Welsh \ No newline at end of file +bbb.langSelector.cy_GB=Welsh diff --git a/bigbluebutton-client/locale/pt_BR/bbbResources.properties b/bigbluebutton-client/locale/pt_BR/bbbResources.properties index 16159fe46a..6b236a1e3a 100755 --- a/bigbluebutton-client/locale/pt_BR/bbbResources.properties +++ b/bigbluebutton-client/locale/pt_BR/bbbResources.properties @@ -608,6 +608,7 @@ bbb.lockSettings.feature=Recurso bbb.lockSettings.locked=Bloqueado bbb.lockSettings.lockOnJoin=Restringir ao entrar +bbb.langSelector.default=Idioma padrão bbb.langSelector.ar_SY=Árabe (Síria) bbb.langSelector.az_AZ=Azeri bbb.langSelector.eu_EU=Basco @@ -657,4 +658,4 @@ bbb.langSelector.th_TH=Tailandês bbb.langSelector.tr_TR=Turco bbb.langSelector.uk_UA=Ucraniano bbb.langSelector.vi_VN=Vietnamita -bbb.langSelector.cy_GB=Galês \ No newline at end of file +bbb.langSelector.cy_GB=Galês diff --git a/bigbluebutton-client/src/org/bigbluebutton/util/i18n/ResourceUtil.as b/bigbluebutton-client/src/org/bigbluebutton/util/i18n/ResourceUtil.as index ad9c89dafe..87e1117601 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/util/i18n/ResourceUtil.as +++ b/bigbluebutton-client/src/org/bigbluebutton/util/i18n/ResourceUtil.as @@ -54,6 +54,7 @@ package org.bigbluebutton.util.i18n private static var BBB_RESOURCE_BUNDLE:String = 'bbbResources'; private static var MASTER_LOCALE:String = "en_US"; + private static var DEFAULT_LOCALE_IDENTIFIER:String = "default"; [Bindable] public var locales:Array = new Array(); @@ -108,6 +109,11 @@ package org.bigbluebutton.util.i18n LogUtil.debug("--- Supported locales --- \n" + xml.toString() + "\n --- \n"); var locale:XML; + locales.push({ + code: DEFAULT_LOCALE_IDENTIFIER, + name: "" + }); + for each(locale in list){ locales.push({ code: locale.@code, @@ -137,6 +143,10 @@ package org.bigbluebutton.util.i18n } public function setPreferredLocale(locale:String):void { + if (locale == DEFAULT_LOCALE_IDENTIFIER) { + locale = getDefaultLocale(); + } + LogUtil.debug("Setting up preferred locale " + locale); if (isPreferredLocaleAvailable(locale)) { LogUtil.debug("The locale " + locale + " is available"); @@ -151,12 +161,23 @@ package org.bigbluebutton.util.i18n private function localesCompareFunction(a:Object, b:Object):int { var sorter:Collator = new Collator(preferredLocale, CollatorMode.SORTING); + // position the "Default language" option at the top of the list + if (a.code == DEFAULT_LOCALE_IDENTIFIER) { + return -1; + } + if (b.code == DEFAULT_LOCALE_IDENTIFIER) { + return 1; + } return sorter.compare(a.name, b.name); } private function reloadLocaleNames():void { for each (var item:* in locales) { - item.name = ResourceUtil.getInstance().getString("bbb.langSelector." + item.code, null, preferredLocale); + if (item.code == DEFAULT_LOCALE_IDENTIFIER) { + item.name = ResourceUtil.getInstance().getString("bbb.langSelector." + item.code, null, getDefaultLocale()); + } else { + item.name = ResourceUtil.getInstance().getString("bbb.langSelector." + item.code, null, preferredLocale); + } } locales.sort(localesCompareFunction); } @@ -245,8 +266,12 @@ package org.bigbluebutton.util.i18n * the key is available in the locale and thus not bother falling back to the master locale. * (ralam dec 15, 2011). */ - var localeTxt:String = resourceManager.getString(BBB_RESOURCE_BUNDLE, resourceName, parameters, null); - if ((localeTxt == "") || (localeTxt == null)) { + if (resourceManager.getObject(BBB_RESOURCE_BUNDLE, resourceName, locale) == undefined) { + locale = MASTER_LOCALE; + } + + var localeTxt:String = resourceManager.getString(BBB_RESOURCE_BUNDLE, resourceName, parameters, locale); + if (locale != MASTER_LOCALE && (localeTxt == "" || localeTxt == null)) { localeTxt = resourceManager.getString(BBB_RESOURCE_BUNDLE, resourceName, parameters, MASTER_LOCALE); } return localeTxt;