Nimmi
Nimmi

Reputation: 2017

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!!!

Upvotes: 4

Views: 15855

Answers (3)

SajjadHashmi
SajjadHashmi

Reputation: 3695

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.-->

Upvotes: 4

Amir E. Aharoni
Amir E. Aharoni

Reputation: 1318

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.

Upvotes: 4

Levi Botelho
Levi Botelho

Reputation: 25214

There is no integrated translation in HTML5. HTML provides support for the lang attribute which indicates what language a given tag's content is written in, but this is merely an indicative attribute which does not modify the content in any way.

The more philosophical reasoning behind why there is no automatic translation is that HTML is a structural language... it defines the framework upon which your web page is built. Not only does it not modify content, but if it did you as the developer would lose control over the quality and accuracy of the translation. This could be a very bad thing...

As you must already know, however, Chrome will translate pages in foreign languages for you into your preferred language. The difference here is that Chrome is controlled by the user, who has the power to decide in what language to view the content as well as whether they wish to view the original content which is explicitly defined by you, the developer.


Translation is up to the browser. To translate, you need a translation engine which will actually do the translation for you. As you know, you can't simply convert words one by one and end up with a proper translation in the other language. Chrome leverages the power of Google Translate to translate its pages and this is how it offers this functionality. Your best bet for multilanguage support is to offer your pages in as many languages as you accurately can, and then hope that users who don't use Chrome will plug your URL into Google translate or a similar service to get an approximation of your content in their native tongue.

Upvotes: 2

Related Questions