Browse Source

Added language for mobile settings

master
Igor Zhukov 10 years ago
parent
commit
6baf77da5a
  1. 3
      app/css/mobile.css
  2. 11
      app/js/controllers.js
  3. 10
      app/js/init.js
  4. 11
      app/js/lib/config.js
  5. 2
      app/partials/desktop/lang_footer.html
  6. 10
      app/partials/mobile/settings_modal.html

3
app/css/mobile.css

@ -851,6 +851,9 @@ a.im_message_fwd_author {
.mobile_modal_action_wrap { .mobile_modal_action_wrap {
border-bottom: 1px solid #e0e0e0; border-bottom: 1px solid #e0e0e0;
} }
.mobile_modal_select_wrap {
margin: 7px 12px 0;
}
a.mobile_modal_action, a.mobile_modal_action,
span.mobile_modal_action { span.mobile_modal_action {
color: #000; color: #000;

11
app/js/controllers.js

@ -1453,16 +1453,21 @@ angular.module('myApp.controllers', ['myApp.i18n'])
} }
}) })
.controller('AppLangFooterController', function ($scope, _, Storage, ErrorService, AppRuntimeManager) { .controller('AppLangSelectController', function ($scope, _, Storage, ErrorService, AppRuntimeManager) {
$scope.supportedLocales = Config.I18n.supported; $scope.supportedLocales = Config.I18n.supported;
$scope.langNames = Config.I18n.languages; $scope.langNames = Config.I18n.languages;
$scope.curLocale = Config.I18n.locale; $scope.curLocale = Config.I18n.locale;
$scope.form = {locale: Config.I18n.locale};
$scope.localeSelect = function localeSelect (newLocale) { $scope.localeSelect = function localeSelect (newLocale) {
Storage.set({i18n_locale: newLocale}); newLocale = newLocale || $scope.form.locale;
if ($scope.curLocale !== newLocale) { if ($scope.curLocale !== newLocale) {
ErrorService.confirm({type: 'APPLY_LANG_WITH_RELOAD'}).then(function () { ErrorService.confirm({type: 'APPLY_LANG_WITH_RELOAD'}).then(function () {
AppRuntimeManager.reload(); Storage.set({i18n_locale: newLocale}).then(function () {
AppRuntimeManager.reload();
});
}, function () {
$scope.form.locale = $scope.curLocale;
}); });
} }
}; };

10
app/js/init.js

@ -111,12 +111,10 @@
locale = (navigator.language || '').toLowerCase(); locale = (navigator.language || '').toLowerCase();
locale = Config.I18n.aliases[locale] || locale; locale = Config.I18n.aliases[locale] || locale;
} }
if (!Config.Mobile) { for (var i = 0; i < Config.I18n.supported.length; i++) {
for (var i = 0; i < Config.I18n.supported.length; i++) { if (Config.I18n.supported[i] == locale) {
if (Config.I18n.supported[i] == locale) { Config.I18n.locale = locale;
Config.I18n.locale = locale; break;
break;
}
} }
} }
bootReady.i18n_ng = Config.I18n.locale == defaultLocale; // Already included bootReady.i18n_ng = Config.I18n.locale == defaultLocale; // Already included

11
app/js/lib/config.js

@ -201,7 +201,11 @@ Config.LangCountries = {"es": "ES", "ru": "RU", "en": "US", "de": "DE", "it": "I
function storageRemoveValue () { function storageRemoveValue () {
var keys = Array.prototype.slice.call(arguments), var keys = Array.prototype.slice.call(arguments),
prefix = storageGetPrefix(), prefix = storageGetPrefix(),
i, key; i, key, callback;
if (typeof keys[keys.length - 1] === 'function') {
callback = keys.pop();
}
for (i = 0; i < keys.length; i++) { for (i = 0; i < keys.length; i++) {
key = keys[i] = prefix + keys[i]; key = keys[i] = prefix + keys[i];
@ -211,7 +215,10 @@ Config.LangCountries = {"es": "ES", "ru": "RU", "en": "US", "de": "DE", "it": "I
} }
} }
if (useCs) { if (useCs) {
chrome.storage.local.remove(keys); chrome.storage.local.remove(keys, callback);
}
else if (callback) {
callback();
} }
}; };

2
app/partials/desktop/lang_footer.html

@ -1,4 +1,4 @@
<div class="footer_wrap" ng-controller="AppLangFooterController"> <div class="footer_wrap" ng-controller="AppLangSelectController">
<span ng-repeat="locale in ::supportedLocales"> <span ng-repeat="locale in ::supportedLocales">
<a class="footer_lang_link" ng-class="{active: curLocale == locale, disabled: curLocale == locale}" ng-disabled="curLocale == locale" ng-click="localeSelect(locale)" ng-bind="langNames[locale]"></a> <a class="footer_lang_link" ng-class="{active: curLocale == locale, disabled: curLocale == locale}" ng-disabled="curLocale == locale" ng-click="localeSelect(locale)" ng-bind="langNames[locale]"></a>
<span ng-if="!$last" class="footer_link_divider"></span> <span ng-if="!$last" class="footer_link_divider"></span>

10
app/partials/mobile/settings_modal.html

@ -101,6 +101,16 @@
</a> </a>
</div> </div>
<div class="mobile_modal_action_wrap" ng-controller="AppLangSelectController">
<div class="mobile_modal_select_wrap pull-right">
<select class="form-control" ng-change="localeSelect()" ng-model="form.locale">
<option ng-repeat="locale in ::supportedLocales" value="{{locale}}" ng-bind="langNames[locale]" ng-selected="locale == curLocale"></option>
</select>
</div>
<span class="mobile_modal_action" my-i18n="settings_modal_language"></span>
</div>
<div class="mobile_modal_section" ng-if="profile.phone"> <div class="mobile_modal_section" ng-if="profile.phone">
<h4 class="mobile_modal_section_header" my-i18n="settings_modal_phone"></h4> <h4 class="mobile_modal_section_header" my-i18n="settings_modal_phone"></h4>
<div class="mobile_modal_section_value" ng-bind="profile.phone | phoneNumber"></div> <div class="mobile_modal_section_value" ng-bind="profile.phone | phoneNumber"></div>

Loading…
Cancel
Save