change menu translate

This commit is contained in:
OldHawk
2017-05-05 18:27:22 +08:00
parent 34458aeed4
commit 42f18c5657
17 changed files with 49 additions and 56 deletions

View File

@@ -5,12 +5,12 @@
.module('chat')
.run(menuConfig);
menuConfig.$inject = ['menuService', '$translate'];
menuConfig.$inject = ['menuService'];
function menuConfig(menuService, $translate) {
function menuConfig(menuService) {
// Set top bar menu items
menuService.addMenuItem('topbar', {
title: $translate.instant('MENU_CHAT'),
title: 'MENU_CHAT',
state: 'chat',
roles: ['*'],
position: 2

View File

@@ -32,7 +32,6 @@
localStorageModuleConfig.$inject = ['localStorageServiceProvider'];
function localStorageModuleConfig(localStorageServiceProvider) {
console.log('localStorageModuleConfig');
localStorageServiceProvider
.setPrefix('meanTorrent')
.setStorageType('localStorage')
@@ -42,13 +41,11 @@
transConfig.$inject = ['$translateProvider'];
function transConfig($translateProvider) {
console.log('transConfig');
$translateProvider.useSanitizeValueStrategy(null);
}
setDefaultLang.$inject = ['$translate', 'getStorageLangService'];
function setDefaultLang($translate, getStorageLangService) {
console.log('setDefaultLang');
var user_lang = getStorageLangService.getLang();
$translate.use(user_lang);

View File

@@ -5,11 +5,11 @@
.module('core.admin')
.run(menuConfig);
menuConfig.$inject = ['menuService', '$translate'];
menuConfig.$inject = ['menuService'];
function menuConfig(menuService, $translate) {
function menuConfig(menuService) {
menuService.addMenuItem('topbar', {
title: $translate.instant('MENU_ADMIN'),
title: 'MENU_ADMIN',
state: 'admin',
type: 'dropdown',
roles: ['admin'],

View File

@@ -5,9 +5,9 @@
.module('core')
.run(menuConfig);
menuConfig.$inject = ['menuService', '$translate'];
menuConfig.$inject = ['menuService'];
function menuConfig(menuService, $translate) {
function menuConfig(menuService) {
menuService.addMenu('account', {
roles: ['user']
});
@@ -20,22 +20,22 @@
});
menuService.addSubMenuItem('account', 'settings', {
title: $translate.instant('EDIT_PROFILE'),
title: 'EDIT_PROFILE',
state: 'settings.profile'
});
menuService.addSubMenuItem('account', 'settings', {
title: $translate.instant('EDIT_PROFILE_PIC'),
title: 'EDIT_PROFILE_PIC',
state: 'settings.picture'
});
menuService.addSubMenuItem('account', 'settings', {
title: $translate.instant('CHANGE_PASSWORD'),
title: 'CHANGE_PASSWORD',
state: 'settings.password'
});
menuService.addSubMenuItem('account', 'settings', {
title: $translate.instant('MANAGE_SOCIAL_ACCOUNTS'),
title: 'MANAGE_SOCIAL_ACCOUNTS',
state: 'settings.accounts'
});
}

View File

@@ -5,9 +5,9 @@
.module('core')
.controller('HomeController', HomeController);
HomeController.$inject = ['$scope', '$state', '$translate', 'TorrentsService', 'Notification', 'MeanTorrentConfig'];
HomeController.$inject = ['$scope', '$state', '$translate', 'TorrentsService', 'Notification', 'MeanTorrentConfig', 'getStorageLangService'];
function HomeController($scope, $state, $translate, TorrentsService, Notification, MeanTorrentConfig) {
function HomeController($scope, $state, $translate, TorrentsService, Notification, MeanTorrentConfig, getStorageLangService) {
var vm = this;
vm.tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig;
vm.movieTopList = undefined;
@@ -23,7 +23,7 @@
vm.initInfo = function () {
TorrentsService.getTMDBInfo({
tmdbid: '329865',
language: 'en'
language: getStorageLangService.getLang()
}, function (res) {
Notification.success({
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('TMDB_ID_OK')

View File

@@ -21,7 +21,6 @@
var menu_title = attrs.menuTitle;
var trans = $translate.instant(menu_title);
attrs.$set('ng-bind', trans);
element.html(trans);
}
}

View File

@@ -8,15 +8,12 @@
function getStorageLangService() {
this.$get = ['localStorageService', function (localStorageService) {
var getLang = function () {
console.log('getStorageLangService getLang');
var user_lang = navigator.language || navigator.userLanguage;
user_lang = user_lang.substr(0, 2) || 'en';
console.log('local_lang=' + user_lang);
var storage_lang = localStorageService.get('storage_user_lang');
user_lang = storage_lang || user_lang;
console.log('user_lang=' + user_lang);
return user_lang;
};

View File

@@ -5,12 +5,12 @@
.module('forums')
.run(menuConfig);
menuConfig.$inject = ['menuService', '$translate'];
menuConfig.$inject = ['menuService'];
function menuConfig(menuService, $translate) {
function menuConfig(menuService) {
// Set top bar menu items
menuService.addMenuItem('topbar', {
title: $translate.instant('MENU_FORUMS'),
title: 'MENU_FORUMS',
state: 'forums',
roles: ['*'],
position: 1

View File

@@ -5,11 +5,11 @@
.module('ranking')
.run(menuConfig);
menuConfig.$inject = ['menuService', '$translate'];
menuConfig.$inject = ['menuService'];
function menuConfig(menuService, $translate) {
function menuConfig(menuService) {
menuService.addMenuItem('topbar', {
title: $translate.instant('MENU_RANKING'),
title: 'MENU_RANKING',
state: 'ranking',
roles: ['*'],
position: 4

View File

@@ -5,11 +5,11 @@
.module('rules')
.run(menuConfig);
menuConfig.$inject = ['menuService', '$translate'];
menuConfig.$inject = ['menuService'];
function menuConfig(menuService, $translate) {
function menuConfig(menuService) {
menuService.addMenuItem('topbar', {
title: $translate.instant('MENU_RULES'),
title: 'MENU_RULES',
state: 'rules',
roles: ['*'],
position: 5

View File

@@ -6,11 +6,11 @@
.module('torrents.admin')
.run(menuConfig);
menuConfig.$inject = ['menuService', '$translate'];
menuConfig.$inject = ['menuService'];
function menuConfig(menuService, $translate) {
function menuConfig(menuService) {
menuService.addSubMenuItem('topbar', 'admin', {
title: $translate.instant('MENU_TORRENTS_ADMIN'),
title: 'MENU_TORRENTS_ADMIN',
state: 'admin.torrents.list',
position: 1
});

View File

@@ -5,13 +5,11 @@
.module('torrents')
.run(menuConfig);
menuConfig.$inject = ['menuService', '$translate'];
function menuConfig(menuService, $translate) {
console.log('menuConfig');
menuConfig.$inject = ['menuService'];
function menuConfig(menuService) {
menuService.addMenuItem('topbar', {
title: $translate.instant('MENU_TORRENTS'),
title: 'MENU_TORRENTS',
state: 'torrents',
type: 'dropdown',
roles: ['*'],
@@ -20,27 +18,27 @@
// Add the dropdown list item
menuService.addSubMenuItem('topbar', 'torrents', {
title: $translate.instant('MENU_TORRENTS_SUB.SUB_MOVIE'),
title: 'MENU_TORRENTS_SUB.SUB_MOVIE',
state: 'torrents.movie',
roles: ['*']
});
menuService.addSubMenuItem('topbar', 'torrents', {
title: $translate.instant('MENU_TORRENTS_SUB.SUB_MTV'),
title: 'MENU_TORRENTS_SUB.SUB_MTV',
state: 'torrents.mtv',
roles: ['*']
});
menuService.addSubMenuItem('topbar', 'torrents', {
title: $translate.instant('MENU_TORRENTS_SUB.SUB_MUSIC'),
title: 'MENU_TORRENTS_SUB.SUB_MUSIC',
state: 'torrents.music',
roles: ['*']
});
menuService.addSubMenuItem('topbar', 'torrents', {
title: $translate.instant('MENU_TORRENTS_SUB.SUB_OTHER'),
title: 'MENU_TORRENTS_SUB.SUB_OTHER',
state: 'torrents.other',
roles: ['*']
});
menuService.addMenuItem('topbar', {
title: $translate.instant('MENU_UPLOAD'),
title: 'MENU_UPLOAD',
state: 'torrents.uploads',
roles: ['*'],
position: 3

View File

@@ -7,11 +7,11 @@
TorrentsInfoController.$inject = ['$scope', '$state', '$stateParams', '$translate', 'Authentication', 'Notification', 'TorrentsService',
'MeanTorrentConfig', 'DownloadService', '$sce', '$filter', 'CommentsService', 'ModalConfirmService', 'marked', 'Upload', '$timeout',
'SubtitlesService', 'uibButtonConfig'];
'SubtitlesService', 'getStorageLangService'];
function TorrentsInfoController($scope, $state, $stateParams, $translate, Authentication, Notification, TorrentsService, MeanTorrentConfig,
DownloadService, $sce, $filter, CommentsService, ModalConfirmService, marked, Upload, $timeout, SubtitlesService,
uibButtonConfig) {
getStorageLangService) {
var vm = this;
vm.user = Authentication.user;
vm.announce = MeanTorrentConfig.meanTorrentConfig.announce;
@@ -187,7 +187,7 @@
vm.initInfo = function (tmdb_id) {
TorrentsService.getTMDBInfo({
tmdbid: tmdb_id,
language: 'en'
language: getStorageLangService.getLang()
}, function (res) {
Notification.success({
message: '<i class="glyphicon glyphicon-ok"></i> ' + $translate.instant('TMDB_INFO_OK')

View File

@@ -6,10 +6,10 @@
.controller('TorrentsUploadController', TorrentsUploadController);
TorrentsUploadController.$inject = ['$scope', '$state', '$translate', '$timeout', 'Authentication', 'MeanTorrentConfig', 'Upload', 'Notification',
'TorrentsService'];
'TorrentsService', 'getStorageLangService'];
function TorrentsUploadController($scope, $state, $translate, $timeout, Authentication, MeanTorrentConfig, Upload, Notification,
TorrentsService) {
TorrentsService, getStorageLangService) {
var vm = this;
vm.announce = MeanTorrentConfig.meanTorrentConfig.announce;
vm.tmdbConfig = MeanTorrentConfig.meanTorrentConfig.tmdbConfig;
@@ -130,7 +130,7 @@
vm.tmdb_isloading = true;
TorrentsService.getTMDBInfo({
tmdbid: tmdbid,
language: 'en'
language: getStorageLangService.getLang()
}, function (res) {
vm.tmdb_info_ok = true;
vm.tmdb_isloading = false;

View File

@@ -5,12 +5,12 @@
.module('users.admin')
.run(menuConfig);
menuConfig.$inject = ['menuService', '$translate'];
menuConfig.$inject = ['menuService'];
// Configuring the Users module
function menuConfig(menuService, $translate) {
function menuConfig(menuService) {
menuService.addSubMenuItem('topbar', 'admin', {
title: $translate.instant('MENU_USERS_ADMIN'),
title: 'MENU_USERS_ADMIN',
state: 'admin.users'
});
}

View File

@@ -5,11 +5,11 @@
.module('vip')
.run(menuConfig);
menuConfig.$inject = ['menuService', '$translate'];
menuConfig.$inject = ['menuService'];
function menuConfig(menuService, $translate) {
function menuConfig(menuService) {
menuService.addMenuItem('topbar', {
title: $translate.instant('MENU_VIP'),
title: 'MENU_VIP',
state: 'vip',
roles: ['*'],
position: 6

View File

@@ -15,8 +15,10 @@
if (o === 'en') {
localStorageService.set('storage_user_lang', 'zh');
$translate.use('zh');
} else {
localStorageService.set('storage_user_lang', 'en');
$translate.use('en');
}
};
}