【发布时间】:2016-06-03 17:51:49
【问题描述】:
我需要帮助!我试图在我的 controller.js 中更改 defaultLocale,并且我正在使用带角度的 i18n。结构为:
angular.module('starter.controllers', ['ngLocalize', 'ngLocalize.Config'])
.value('localeConf', {
basePath: 'js/Locales',
defaultLocale: 'pt-BR',
sharedDictionary: 'common',
fileExtension: '.lang.json',
...
指令:
.controller('ConfiguracaoCtrl', function ($scope,... , locale, localeConf) {...
和功能:
$scope.selecionaIdioma = function(idioma){
localeConf.defaultLocale = idioma; //tried to set a language
localStorage.setItem("appIdioma",idioma);
}
我有翻译语言的文件:js > locales > es-CL > common.lang.json 和 js > locales > pt-BR > common.lang.json
“defaultLocale”已更改,但语言未更改。请问,知道我做错了什么吗?
【问题讨论】:
-
一点.. 在我的 app.js.. 我也有: angular.module('starter', ['ionic', .., 'ngLocalize', 'ngLocalize.Config']) .value('localeConf', { basePath: 'js/Locales', defaultLocale: 'pt-BR', sharedDictionary: 'common', fileExtension: '.lang.json', ...“选择语言”在我的controller.js .. 所以我需要在我的 app.js 中设置“defaultLocale”。这可能吗?
标签: angularjs ionic-framework internationalization