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
- Host: GitHub
- URL: https://github.com/piyalidas10/language-translator
- Owner: piyalidas10
- Created: 2017-06-16T02:29:40.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-17T04:22:53.000Z (about 9 years ago)
- Last Synced: 2025-04-07T12:16:18.640Z (about 1 year ago)
- Topics: angular1, angularjs, controller, json, language-translator, multi-language
- Language: HTML
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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: