Re: how to do i18n of javascript file with Wicket?

2012-02-16 Thread infiniter
I have the exact same issue.. What did you decide for your problem?
I'm trying to decide now what the best approach is. Two of my options were
exactly the ones you describe to improve your design, but the one that I
currently have is a template, which looks like this:

var someData= {
   'msg'='${message:hello}';
   'a'='${message:min}';
   'b'='${message:max}';
}

The nasty part is that for each JS template you have to create your
variables model, which is just a hashmap. I have a simple function that
looks like:

addMessageToVariablesMap(variablesMap, min);

I don't like having to provide a variables model to get the messages, but
instead I'd like to make the message-resolving part automatic just like
wicket:message in the markup files. I still haven't done that. 

Ideas are welcome.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/how-to-do-i18n-of-javascript-file-with-Wicket-tp1867123p4396038.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



how to do i18n of javascript file with Wicket?

2008-06-01 Thread Quan Zhou
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
a.zh_CN.html
while
put  script language=javascript src=js/area_zh_TW.js/script in
a.zh_TW.html

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


Re: how to do i18n of javascript file with Wicket?

2008-06-01 Thread Erik van Oosten
We use approach 1. We do not pull messages from Wicket resources, they 
are just static in the file. The link to the correct js file is however 
created by a dynamic component that uses the current Locale.


You could go with approach 2, but to me it  sounds like a lot of work.

Regards,
   Erik.

Quan Zhou wrote:

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



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]