0

Datebox locale gl_ES

asked 2018-03-13 21:46:00 +0800

idosil gravatar image idosil
1

Hi, there. I'm developing a multi-language application running on ZK and JDK 1.6 (IBM). For the gl_ES locale, Datebox is showing weekdays and months in English. I can see ZK is resorting to JDK's i18n built in support in order to get the corresponding translations, but they are not included in the JDK. I am not allowed to add an SPI extension, either. The only alternative I can see is to replace org.zkoss.zk.ui.http.Wpds with my own version. Specifically adding support to gl_ES in method getDateJavaScript.

Does ZK provide an alternative means to get weekday and month translations?

Regards.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-03-14 14:53:29 +0800

cor3000 gravatar image cor3000
4293 1 7
ZK Team

as you say, you can't use the default mechanism provided by Java itself so that a custom approach is needed.

As you might have noticed already the localized date strings are contained in "zul.lang.wpd" and you already found that the Wdps class is not designed to be extensible.

Since wpd-files just contain ordinary JS you can simply redefine the values via JS as needed.

e.g.

zk.S2DOW=['Su_gl','Mo_gl','Tu_gl','We_gl','Th_gl','Fr_gl','Sa_gl'];

Will replace the weekday labels rendered in a calendar control. Other labels can be redefined in the same way. To automate this you can load a locale dependent JS file in a zul file as follows:

<?script src="~./custom-date-labels*.js"?>
<zk>
  Current Locale: ${Locales.getCurrent().toString()}
  <calendar/>
</zk>

The "~." will search the file in your classpath below the "web" package. e.g. in (when the current locale is gl_ES) for all other locales you can provide an empty fallback file

src/main/resources/web/custom-date-labels_gl_ES.js src/main/resources/web/custom-date-labels.js (empty fallback, no overrides)

exemplary content of custom-date-labelsglES.js

zk.afterLoad('zul.lang', function() {
    zk.DOW_1ST=1;
    zk.MINDAYS=1;
    zk.ERA="AD";
    zk.YDELTA=0;
    zk.SDOW=['Su_gl','Mo_gl','Tu_gl','We_gl','Th_gl','Fr_gl','Sa_gl'];
    zk.S2DOW=zk.SDOW;
    zk.FDOW=['Sunday_gl','Monday_gl','Tuesday_gl','Wednesday_gl','Thursday_gl','Friday_gl','Saturday_gl'];
    zk.SMON=['Jan_gl','Feb_gl','Mar_gl','Apr_gl','May_gl','Jun_gl','Jul_gl','Aug_gl','Sep_gl','Oct_gl','Nov_gl','Dec_gl'];
    zk.S2MON=zk.SMON;
    zk.FMON=['January_gl','February_gl','March_gl','April_gl','May_gl','June_gl','July_gl','August_gl','September_gl','October_gl','November_gl','December_gl'];
    zk.APM=['AM','PM'];
});//zk.afterLoad

You can remove variables you don't want to override or add additional ones as needed.

I hope this helps

Robert

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2018-03-13 21:46:00 +0800

Seen: 7 times

Last updated: Mar 14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More