How to add a language Dropbox | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to add a language Dropbox

When creating a website, how do you add a language section where the viewers can change between different language of their preference?

5th Mar 2021, 10:02 PM
Destin Smith
5 Answers
+ 2
it is used to indicate the language used... but it has no behavior defaulted to it. you could use it to target elements to be displayed and to be hidden if you build a multi-lang single page ;) you could also use google translate api to dynamically translate your text content...
6th Mar 2021, 4:57 PM
visph
visph - avatar
+ 1
Hi! In the simple version, you create copies of this page in different languages. or do you know other ways?
5th Mar 2021, 10:07 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
you could also write only one page with text contents duplicated and marked with some class name (one for each lang), then you are able to display only selected language and hide others ^^ (you should add some url parameter with language selected -- or store it in a cookie or webStorage -- and check it on page load to switch to the expected language)
5th Mar 2021, 10:41 PM
visph
visph - avatar
0
what is the purpose of the <lang> attribute if it doesn’t change the webpage language?
6th Mar 2021, 4:53 PM
Destin Smith
0
You answered mu question. Thanks!
6th Mar 2021, 7:13 PM
Destin Smith