0

I'm a junior front-end developer based in Egypt, so most of what I work on will be in Arabic but I will also need to support English since it is the standard website language used.

I'm looking for a solution to help my clients toggle between multiple languages. Should I build an entire project twice or what is their a better solution to switch languages on a wbeite?

Please keep in mind that I'm still a junior developer with just 2 years of experience.

  • 1
    Please, first thing to do: read [ask], then you can create a question that fits StackOverflow patterns and then we can help. Right now, your question is off-topic – Calvin Nunes Feb 26 '20 at 16:34

1 Answers1

0

You can declare the language of websites in the <html> tag, e.g. <html lang="en">. Therefore, you should be able to save your original website/project in one language and then save another copy of your website/project with the other language you'd like to show.

Read more about declaring languages in HTML

If you want to do all of this on one page only, you can use JavaScript to change the page's language using an onclick function. MDN has a good tutorial using onclick here. However, this is more complicated since you'll need to use a dictionary, such as Google's Cloud Translation API.

  • "You can use JavaScript to change the page's language using an onclick function" — How? – Quentin Feb 26 '20 at 16:56
  • @Quentin Good catch. I was thinking of altering the `lang` attribute of elements, but you're not able to automatically translate using that. I believe you'd need a dictionary and translate using JavaScript, but simply changing the `lang` won't do anything. –  Feb 26 '20 at 17:11