开发者

JQuery Dynamic Page Best Way for multi-language?

I'm starting a new project and one of the requirements is that it needs to support more than one language.

At the moment I am planning on making a jQuery/AJAX based application where all the code is jQuery and it only calls some JSONs to get data.

What would be the best way to implement multi-language on it?

I've been thi开发者_StackOverflow社区nking of something like

<div>LANG_SOME_STRING</div>

and then having some function replace the string with the translated value. But it would become kinda heavy running it every time something happens in the page.

All the feedback is welcome.


Usually what you do is set meta language tags

<meta http-equiv="content-language" content="en">

Then what you have in your database is multiple copies of stuff in different languages you support, usually referred to as Resources.

Your server side code before rendering pages, and your jquery ajax code should include to read this resource language option, before loading the page so they pick the right language.

I can get more technical once you say which language you are using in the backend

Also you might want to create friendly urls that sends the user to a particular language or set it dynamically by geo locating the user ip. e.g. users from Japan automatically get the content in Japanese.

This is a fantastic tutorial on the details of PHP internationalisation process


From experience, jquery is not the library for this type of work... At the moment there are better alternatives such as angularJS that help a lot in this kind of problem. If i could talk to "past me" that what I would tell...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜