i`m need to create multi language Client Side Application, can you help me with my problem.
I have files
index.html
<!DOCTYPE html>
<html ng-app="app" ng-controller="Language as lang">
<head>...</head>
<body>
<div>{{lang.translation.GameName}}</div>
<script type="text/javascript" src="/js/less.min.js"></script>
<script type="text/javascript" src="/js/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/js/main.js"></script>
</body>
</html>
services.ang.js
app.service('TranslateSRV', '$scope', '$http', function($scope){
$scope.translateText = function($scope, $http, language){
$http.get('../json/language.json').then(function(data){
return data.data[language];
});
};
});
controllers.ang.js
app.controller('Language', 'TranslateSRV', function(TranslateSRV){
this.language = 'en';
this.translation = {};
this.translate = function() {
this.translation = TranslateSRV.translateText($scope, $http,this.language);
};
this.translate();
});
language.json
{
"ua":{
"GameName":"Правда або дія",
"ChoseLang":"Оберіть мову гри"
},
"ru":{
"GameName":"Правда или действие",
"ChoseLang":"Выберите язык игры"
},
"en":{
"GameName":"Truth or Dare",
"ChoseLang":"Please choose game language"
}
}
When I`m run page i see nothing, but i had some errors in my browser console.
Errors
Argument 'Language' is not a function, got string