-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I have written some client constraints and I would like to endow them with internationalized messages, just like zk shipped simple constraints. By peeping into the source js code I've learned the labels in the mefainfo/mesg/msgzul bundles get loaded into the global js var msgzul and then can be used by the constraint code, like this:
outOfRangeValue: function () { return msgzul.OUT_OF_RANGE + ': ' + (this._beg != null ? this._end != null ? new zk.fmt.Calendar(null, this._localizedSymbols).formatDate(this._beg, this.format) + " ~ " + new zk.fmt.Calendar().formatDate(this._end, this.format) : ">= " + new zk.fmt.Calendar().formatDate(this._beg, this.format): "<= " + new zk.fmt.Calendar().formatDate(this._end, this.format)); }
As a matter of fact I've created an specialized msgzul_es_ES.properties file in order to rewrite most of the messages and they get loaded fine. But I've been unable to understand
1) how placeholder i18nized messages like
#-=DATE_REQUIRED 2042={ Debe especificar una fecha, en lugar de {0}. Formato: {1}. }
2) what's the purpose of the codes (2042 in the example above) that make up the keys in these properties files
3) what's the magic that makes #-=DATE_REQUIRED appear as a member in the msgzul global js var
4) why the magic does not work if I write something like
#-=TOTAL_DIGIT_COUNT 2060=Número total de dígitos
With kind regards
César Varona
I finally managed to solve it, although not the way I'd preferred. I found the code that populates the msgzul js object; it's to be found in zul's zk.wpd:
<function class="org.zkoss.zul.impl.Utils" signature="java.lang.String outLocaleJavaScript()"/>
I mimicked the outLocaleJavaScript() code and invoked the js it generates on the client side via Clients.evalJavaScript. Everything works fine, but I'd rather do it in a cleaner way, if available.
By the way, this section explains how to change a particular zk message for a given locale. But, what if I'd like to completely replace one msgzul_*.properties with another? Can I write my own, say msgzul_es.properties, and place it somewhere so that zk loads it instead of the shipped msgzul_es.properties?
With kind regards
César Varona
Asked: 2012-06-19 14:45:38 +0800
Seen: 160 times
Last updated: Jun 20 '12