Reputation: 55
I wanted to know how to make my web a multi-language website using angularjs so it won't load the whole page on click. i thought making a controller that have an array that has a language code for the whole site on each outer index like.
language [0]
has name : name, last : lastlanguage [1]
has the same in other language and when you will
choose english the value of the ouuter index changes from 0 to 1 and
so on...what is the best way to do it?
language[0]{name:name,last:last}
Upvotes: 0
Views: 3548
Reputation: 192
Along with the approach by "Ali BAGHO" if you can create a custom angularJS filter that can take arguments which is a selected language, you can translate the page dynamically on a button click. since filters are undergo $digest cycle on every model associated changes it will dynamically update the DOM with new translated text.
You can also refer to this link for more info on how this can be implemented in Angular5
Upvotes: 0
Reputation: 366
I know Im quite late but i think one way i would do it is using json format and maybe link the data in model using angular, something like this :
{
"config": {
"default": "en"
},
"language": {
"en": {
"title": "Title",
"home": "Home",
"contact": "Contact-us"
},
"fr": {
"title": "Titre",
"home": "Menu Principal",
"contact": "Contactez nous",
}
}
}
Consider voting for a correct answer.
Upvotes: 0
Reputation: 940
I can recommend using angular-translate angular-translate
Upvotes: 1