0

ZK internationalization taglib

asked 2011-01-17 08:04:43 +0800

Steva77 gravatar image Steva77 flag of Italy
1014 3
http://www.research.softe...

I tried to find a solution for this silly problem but couldn't find a fitting example:

in i3-label_EN.properties I have:

general.application.welcome = Welcome, {0}!


and I want to use in index.zul something like:
...
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
...
<label value="${c:l('general.application.welcome', ${desktop.execution.userPrincipal.name} )}"/>
...

but I just can't find the right syntax to pass a parameter (or more than one) to c:l function.

Thanks in advance,
Stefano

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2011-01-17 15:49:54 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

only a hint:

tooltiptext="${c:l('common.Booking.KontoKategorie')} ${c:l('btnEdit.tooltiptext')}"

Can you try this:
--> <label value="${c:l('general.application.welcome')} ${desktop.execution.userPrincipal.name} )}"/>

best
Stephan

link publish delete flag offensive edit

answered 2011-01-18 03:06:19 +0800

Steva77 gravatar image Steva77 flag of Italy
1014 3
http://www.research.softe...

Hi Stephan,
thanks for the feedback.
I do not fullt understand your suggestion, as the tooltip example leaves the second parameter out of the c:l function...

This version instead:

title="${c:l('general.application.welcome' ${desktop.execution.userPrincipal.name} )}!"


returns
org.zkoss.xel.XelException: Encountered "$", expected one of [".", ">", "gt", "<", "lt", "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", ")", ",", "[", "+", "-", "*", "/", "div", "%", "mod", "and", "&&", "or", "||", "?"]
	org.zkforge.apache.commons.el.ExpressionEvaluatorImpl.parseExpressionString(ExpressionEvaluatorImpl.java:311)
	org.zkforge.apache.commons.el.ExpressionEvaluatorImpl.parseExpression(ExpressionEvaluatorImpl.java:235)
	org.zkoss.xel.el.ELFactory.parseExpression(ELFactory.java:55)
	org.zkoss.zk.xel.impl.SimpleEvaluator.parseExpression(SimpleEvaluator.java:63)
	org.zkoss.zk.ui.metainfo.AbstractEvalRef.parseExpression(AbstractEvalRef.java:41)
	org.zkoss.zk.xel.ExValue.init(ExValue.java:120)
	org.zkoss.zk.xel.ExValue.getValue(ExValue.java:108)
	org.zkoss.zk.ui.metainfo.Property.getValue(Property.java:138)
	org.zkoss.zk.ui.metainfo.Property.assign0(Property.java:231)
	org.zkoss.zk.ui.metainfo.Property.assign(Property.java:173)
	org.zkoss.zk.ui.metainfo.ComponentInfo.applyProperties(ComponentInfo.java:829)
	org.zkoss.zk.ui.impl.AbstractUiFactory.newComponent(AbstractUiFactory.java:93)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:714)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:685)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:629)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:596)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:730)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:685)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:629)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:661)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:629)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:596)
	org.zkoss.zk.ui.impl.UiEngineImpl.createComponents(UiEngineImpl.java:926)
	org.zkoss.zk.ui.impl.AbstractExecution.createComponents(AbstractExecution.java:231)
	org.zkoss.zul.Include.afterCompose(Include.java:390)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:736)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:685)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:629)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:661)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:629)
	org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:596)
	org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:382)
	org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:305)
	org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:225)
	org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:146)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


The same happens with
${c:l('general.application.welcome'; ${desktop.execution.userPrincipal.name} )}


returning
org.zkoss.xel.XelException: Encountered ";", expected one of [".", ">", "gt", "<", "lt", "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", ")", ",", "[", "+", "-", "*", "/", "div", "%", "mod", "and", "&&", "or", "||", "?"]
...


I found a similar issue at http://www.zkoss.org/forum/listComment/10214 but just can't find c:l2 usage reference or updates in ZK5.

I hope there is a way to do it - I think the native JSP tag library allowed this, it is useful to pass values to internationalized messages!

link publish delete flag offensive edit

answered 2011-01-18 04:26:25 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Hi Steeva,

i would only show how do i do such things with two values.

label="${c:l('common.Details')} secondUntranslatedValue"

label="${c:l('common.Details')} ${common.translated} )}"/>


By a look in the class org.zkoss.util.resource.Labels i cannot see the implementation for working with parameters for inserting values. Only parameter for formatting.

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2011-01-17 08:04:43 +0800

Seen: 442 times

Last updated: Jan 18 '11

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