alon.a
alon.a

Reputation: 55

multi-language website with angular

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.

what is the best way to do it?

language[0]{name:name,last:last}

Upvotes: 0

Views: 3548

Answers (3)

Ravi Teja
Ravi Teja

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

Ali BAGHO
Ali BAGHO

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

Guenter Guckelsberger
Guenter Guckelsberger

Reputation: 940

I can recommend using angular-translate angular-translate

Upvotes: 1

Related Questions