An open API service indexing awesome lists of open source software.

https://github.com/piyalidas10/language-translator

Language translator using angularjs
https://github.com/piyalidas10/language-translator

angular1 angularjs controller json language-translator multi-language

Last synced: 5 months ago
JSON representation

Language translator using angularjs

Awesome Lists containing this project

README

          

# Language-Translator

In this select box, i am fetching the lists of languages that were coming from languages.json file.


in this select box, ng-init will not work because it is called before json file load. so i have initialized the select box with first value of json data in app.js.

$scope.selectlang = $scope.langs[0];

I have used "track by lang.value" to show languages.json file's value, otherwise select box option value will show object.

ng-options="lang.name for lang in langs track by lang.value"

Get the selected option value using changelan function and pass selectlang value through this function. This selectlang value is kept in selectedItems variable and passing this variable to $scope.link, we can access the json file of selected language. Then call again changejson() function to change the json file.

ng-change="changelan(selectlang)"


$scope.changelan = function(val){
$scope.selectedItems = val.value;
console.log($scope.selectedItems);
$scope.link = 'JSON/content-'+$scope.selectedItems+'.json';
$scope.changejson();
}

The name of json files are given like content-ben.json, content-en.json, content-hi.json.

And also apply the following change to the markup: