Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do localization on web application?

There is several way to do so, I can define all the text element, and load the localization string json from javascript, and using some javascript to replace text to do so... Also, I check out there is some other way to do so too. For example, some is using platform depends way to do that. For example, the J2EE have it own way to implement it. Also, I can create separate page for each language.

But is there any way to do localization is flexible or suggested? Thank you.

like image 494
Tattat Avatar asked Dec 12 '10 09:12

Tattat


People also ask

What is localization in web application?

Website localization is the process of adapting an existing website to local language and culture in the target market. It is the process of adapting a website into a different linguistic and cultural context— involving much more than the simple translation of text.

How is localization done?

Localization is the process of adapting a piece of content's full meaning for a new region, including translation, associated imagery, and cultural elements that influence how your content will be perceived. Localization is all about making your website feel like it was written with that audience in mind.


2 Answers

It seems to me that what you are really asking for is: How to implement Localizability correctly? Or how to program in order to make it easy to localize an application.

That is actually Internationalization-related question. There are several things you need to keep in mind in order to make your application easy to localize:

  • Do not hardcode strings (that one is obvious)
  • Do not hardcode styling information (do not use formatting tags like <b>, <i>, <strong>, etc.; do not use this: <p style="font-weight: bold;color: green;">Success!</p>). This will prevent localization guys from modifying them (i.e. removing bolded text from CJKV translations)
  • Avoid using compound messages (like "Function [A,B,C] does [a,b,c]"). They are pretty hard to translate correctly. If you do not have a lot of variables it won't hurt to add few more strings out in resources.
  • Do not concatenate compound messages either with concatenate operator or just by placing strings next to each other (i.e. don't do this: String message = "Function " + function + " does " + whatItDoes; or this: #{['something']}<a href="whatever">#{['some_link']}</a>#{['something_else']}), use formatting instead (i.e. MessageFormat.format("Hello, {0}. You have {1} new messages.", name, mailCount);). This won't allow the Translator to re-order the sentence and it might be required due to target's language grammar rules.
  • Do not use raw placeholders (like %s %i %u) if you have more than one of that kind in a sentence (it is actually better to use numbered placeholder like {0}, {1} instead). Again, sometimes translators need to re-order the sentence...
  • Do not use language constructs specific to English (i.e. "Paweł's dashboard" where Paweł is a name I provided during registration). There is no way to translate it correctly to several languages

Also, there are things to do:

  • Do provide style sheet override mechanism (so that localization guys could modify element's style)
  • Assign unique id for each element of rendered HTML page (this will allow them to target the exact control with their overridden style)
  • Use UTF-8 encoding wherever you can (obviously HTML pages, e-mails if any, but possibly resource files [i.e. properties] as well)

There is much more things not related to localizability, like language detection workflow, formatting and validating numbers, currencies, dates (including setting proper timezones) that you would need to care about in properly globalized application, but that's actually different story.

like image 186
Paweł Dyda Avatar answered Oct 19 '22 16:10

Paweł Dyda


Almost all decent web development frameworks out there have a notion of localized "resource bundles". You just make sure that you have a resource bundle for each supported language by your application, wherein each one of them uses the same "key" to refer to a localized string. Just use the facility provided by the framework/language to load the text from the bundle based on the "key" and you should be good to go.

As far as locale detection goes, there are again two ways of doing it; auto-detection, which is a fairly common mechanism used by web applications and selection based mechanism which uses a combination of auto-detection along with a locale drop-down provided to the user.

Specific steps would be language/framework specific so you might want to mention the framework which you are using for specific answers.

like image 37
Sanjay T. Sharma Avatar answered Oct 19 '22 15:10

Sanjay T. Sharma