Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Support for Multi Language

Does anyone have any idea that HTML5 has multilingual support. I mean to say if I design my website in English and html5 will convert that using some lang or translate or any other supportive tag will convert that web page into a respective language.

Any guidance or bit of code can help me a lot.

Thanks a tons!!!

like image 976
Nimmi Avatar asked Dec 21 '22 12:12

Nimmi


2 Answers

HTML5 doesn't translate anything. It’s simply a markup language that displays the contents you have put inside it without applying any logic to it.

However, such translations are usually done by modern browsers like Chrome, FireFox etc. Advance browsers do detect that the website you are viewing is in some other language and offer you the choice to convert it to your preferred language.

Only thing that HTML5 has in connection with this whole translation thing is that it has a new attribute called translate. By using this attribute with a value of "no" you can now flag elements that you don't want to be translated by browsers:

<span translate="no">衝撞撞沒輸贏」應是「衝衝撞撞沒輸贏</span>
<!--Now no browser will dare to translate this.-->
like image 172
SajjadHashmi Avatar answered Dec 23 '22 02:12

SajjadHashmi


The question is - do you want to auto-translate the content, or do you want to translate the user interface of your website.

By itself HTML5 doesn't really provide complete support for either, only some hints, and even they are not really implemented everywhere.

You can add a Google Translate button to your website, as described at http://www.labnol.org/internet/google-translation-widgets/10135/ , for example. Google Chrome has it built-in and it works for all websites. Other browser may get such functionality in the future, but that is a feature of the browser application and not of HTML.

For translating your site's interface you can use one of the many internationalization libraries. Many CMS's and web frameworks come with such an i18n library. You can also do it client-side, using a library such as jquery.i18n ( https://github.com/wikimedia/jquery.i18n/ ).

(Disclaimer: I am one of the developers of juery.i18n.)

Finally, just a tip about good practice: Do use the lang attribute on all the relevant HTML elements. Even if it's just "en". This is useful for spell checking, picking the correct fonts, translation, etc. Whenever you know the language, specify it. It may seem redundant, but it is needed.

like image 27
Amir E. Aharoni Avatar answered Dec 23 '22 00:12

Amir E. Aharoni