You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by paramjyotsingh <pa...@gmail.com> on 2013/03/20 23:13:35 UTC

Camel velocity template internationalization

I have a scenario where I need to pick velocity based on locale. I have two
problems for this.

Do we any option in velocity endpoint to provide locale information? if not,
do we have option in camel to set some header property in Exchange message
so that velocity template gets picked up automatically for that locale.

For example, suppose we have following velocity template files:
 - email.vm
 - en_email.vm
 - cn_email.vm
 - fr_email.vm

if locale/language code is set to 'fr' then velocity should pick fr_email.vm
and another question how to set this locale/language code in Camel
springDSL.

Please help, i am stuck on this issue, i was not able to find anything in
camel user guide about this.
There is something about IRI, but not sure how that works.

Thanks and Regards.
Paramjyot



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-velocity-template-internationalization-tp5729574.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel velocity template internationalization

Posted by Christian Müller <ch...@gmail.com>.
Camel doesn't care about the locale.
I suggest to have a look how Velocity/Freemarker/... lookup the locale.
Than we can see how we can support it (or whether we already support it).

Best,
Christian

On Tue, Mar 26, 2013 at 7:44 PM, paramjyotsingh <pa...@gmail.com>wrote:

> Claus,
>
> Thanks for the reply.
>
> I could have locale setup as JVM argument, but could you please provide
> information about property or header I need to set in exchange for locale,
> if I plan to have language/locale per exchange.
>
> Could you please elaborate on how camel uses locale property, I mean does
> it
> set's system default locale, I want to know how locale propagates between
> different frameworks/APIs. Is there any standard parameter defined.
>
> Thanks and Regards,
> Paramjyot
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-velocity-template-internationalization-tp5729574p5729861.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Camel velocity template internationalization

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Mar 26, 2013 at 7:44 PM, paramjyotsingh
<pa...@gmail.com> wrote:
> Claus,
>
> Thanks for the reply.
>
> I could have locale setup as JVM argument, but could you please provide
> information about property or header I need to set in exchange for locale,
> if I plan to have language/locale per exchange.
>
> Could you please elaborate on how camel uses locale property, I mean does it
> set's system default locale, I want to know how locale propagates between
> different frameworks/APIs. Is there any standard parameter defined.
>

There is no standard in Java for associating a locale to a "message" /
"request" etc.

If you want to pick a template dynamic based on locale. Then either
maybe Velocity offers an API to tell it which locale to use. And you
can use that.

Or you can use "dynamic to" in Camel. See this link
http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html

With this approach you can use a header with the locale abbreviation
to pick the template. And then use the simple language to build that
dynamic uri. See that link.


> Thanks and Regards,
> Paramjyot
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-velocity-template-internationalization-tp5729574p5729861.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel velocity template internationalization

Posted by paramjyotsingh <pa...@gmail.com>.
Claus,

Thanks for the reply. 

I could have locale setup as JVM argument, but could you please provide
information about property or header I need to set in exchange for locale,
if I plan to have language/locale per exchange.

Could you please elaborate on how camel uses locale property, I mean does it
set's system default locale, I want to know how locale propagates between
different frameworks/APIs. Is there any standard parameter defined.

Thanks and Regards,
Paramjyot 



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-velocity-template-internationalization-tp5729574p5729861.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel velocity template internationalization

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Mar 20, 2013 at 11:13 PM, paramjyotsingh
<pa...@gmail.com> wrote:
> I have a scenario where I need to pick velocity based on locale. I have two
> problems for this.
>
> Do we any option in velocity endpoint to provide locale information? if not,
> do we have option in camel to set some header property in Exchange message
> so that velocity template gets picked up automatically for that locale.
>
> For example, suppose we have following velocity template files:
>  - email.vm
>  - en_email.vm
>  - cn_email.vm
>  - fr_email.vm
>
> if locale/language code is set to 'fr' then velocity should pick fr_email.vm
> and another question how to set this locale/language code in Camel
> springDSL.
>

Which locale do you refer to. The default locale setting on the JVM?
Or is it somehow a dynamic local set per Camel exchange?

I know Freemarker has built-in support for locales out of the box.
Where it will pick the locale using a naming convention.

Not sure if Veloicty has the same. I suggest to check the velocity docs.



> Please help, i am stuck on this issue, i was not able to find anything in
> camel user guide about this.
> There is something about IRI, but not sure how that works.
>
> Thanks and Regards.
> Paramjyot
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-velocity-template-internationalization-tp5729574.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen