I'm developing a mobile app using Ionic framework and I have a big problem to handle the multilanguage functionality for help page.
I have 2 languages (en + de) and I want to load help_en.html or help_de.html depending on the language.
I have set in the main controller the default language and the changeLanguage function which will set the lang in $cookies.language and it's working;
1.View:
<a ng-href="#/help" >
2.MainCtrl -change language function:
$scope.changeLanguage = function(lang) {
$scope.translation=translationService.getTranslation($scope, lang);
$cookies.lang=lang;
};
3.The config from app.js looks something like that :
var myApp = angular.module('MyPetApp', ['ionic', 'config', 'MyApp.controllers', 'ngCordova', 'ngResource', 'ngCookies']);
myApp.config(function($stateProvider, $urlRouterProvider) {
var $cookies;
angular.injector(['ngCookies']).invoke(function(_$cookies_) {
$cookies = _$cookies_;
});
if ($cookies.language==undefined){
$cookies.language = 'en'
}
$stateProvider
.state('default', {
url: "/",
templateUrl: "templates/default.html"
})
.state('help', {
url: '/help',
templateUrl: function (){
return 'templates/help_'+$cookies.lang+'.html'
}
})
$urlRouterProvider.otherwise('/');
});
This is working in chrome but on mobile will stay all the time on "en" language even I change the value from $cookies.language to "de".
What can I do to get this job done? Any ideea ? I really appreciate any help
Thanks