My application's supposed to support both English,Simpilify
Chinese,Traditional Chinese,and even Vietnamese. The great I18N feature of
Wicket helps me solve many i18n problems.
The only remains is how to do i18n of javascript.
Due to the initial design, we put some of messages in the .js file,like
confirm messages or some other tips. I firstly archieved it with change
different js file including in the html head tag.
as :
put  <script language="javascript" src="js/area_zh_CN.js"></script> in
put  <script language="javascript" src="js/area_zh_TW.js"></script> in

you know ,that's really a bad way to do so. Sometimes there's no difference
in those two html files. and the only difference between js files are those
I18N MESSAGE values.

Now I've two ideas to improve my current design.
1) write some js file named "string_zh_CN.js" or "string_zh_TW.js" which
contains all the Message content occurr in ALL the js file, and provide a
method call "getString(message)" that return the correct value in current
LOCALE. Then write a component that can load the specific string.xx_xxx.js
file according to the Server LOCALE and add it in the basic page class which
inherited by all my business page. Finally replace all the Message Value
exists in other js files with "getString("xxx")"

2) design a component <CustomScript> for handling all the js file download
request so that I could use wicket to stream js file content. Then, i could
write wicket:message tag in my js file.I suppose those tag would be replace
with the value I put in the Finally ,replace all the
<script> tag with my custom component.

However I was still searching whether there's any best practice for this
problem?  I would try to implemented both two ideas in the following days.
Is there any attentions I should pay to? and I'm not quite sure about idea 2
would work well.

Any help or advice would be appreicated.
Thanks all.

Reply via email to