add language list config

This commit is contained in:
OldHawk
2017-05-06 13:53:50 +08:00
parent 02cab29737
commit eb371527a9
2 changed files with 17 additions and 1 deletions

View File

@@ -2,6 +2,10 @@
module.exports = {
meanTorrentConfig: {
language: [
{name: 'en', css: '.flag-icon-gb'},
{name: 'zh', css: '.flag-icon-cn'}
],
announce: {
url: 'http://127.0.0.1:3000/announce',
announce_prefix: '[CHD.im].',

View File

@@ -6,7 +6,7 @@
.provider('getStorageLangService', getStorageLangService);
function getStorageLangService() {
this.$get = ['localStorageService', function (localStorageService) {
this.$get = ['localStorageService', 'MeanTorrentConfig', function (localStorageService, MeanTorrentConfig) {
var getLang = function () {
var user_lang = navigator.language || navigator.userLanguage;
user_lang = user_lang.substr(0, 2) || 'en';
@@ -14,6 +14,18 @@
var storage_lang = localStorageService.get('storage_user_lang');
user_lang = storage_lang || user_lang;
var lang_list = MeanTorrentConfig.meanTorrentConfig.language;
var inlist = false;
angular.forEach(lang_list, function (l) {
if (l.name === user_lang) {
inlist = true;
}
});
if (!inlist) {
user_lang = 'en';
}
return user_lang;
};