0

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 : last
  • language [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}

3 Answers 3

1

I can recommend using angular-translate angular-translate

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.