cancel
Showing results for 
Search instead for 
Did you mean: 

Webscript internazionalizables

djimenez
Champ in-the-making
Champ in-the-making
Hello,

I try to internationalize the web script using a resource bundle and tags JSP with freemarker. I probe that this option work correct in a application web with only freemarker (freemarker.jar) but when I aplied this solution to the webscript don't work properly, I think the freemarker .jar of alfresco it's different of the official freemarker. How can I internationalize the text in the template of webscript?

Thanks
9 REPLIES 9

davidc
Star Contributor
Star Contributor
Can you clarify?

Do you mean you've successfully used the message() method in a standalone freemarker template, but not when used in conjunction with a web script.

We use an official freemarker jar.

djimenez
Champ in-the-making
Champ in-the-making
Hi,


I want to internazionalize a webscript, How can I do it?

I see in the freemarker documentation I see I can use jsp tag, in this case I probe use the FMT tag library and a language files.

See this page:
http://freemarker.org/docs/pgui_misc_servlet.html

In alfresco don't work this option because in the web.xml you have to define servlet and a maping to ftl extension. The webscripts don't have extension .ftl, then this servlet don't process the petition of webscript.

I searched as internationalize freemarker and did't found other manner.

Do you know how internationalize the webscript?

Thank u.

davidc
Star Contributor
Star Contributor
The page you refer to describes how to use Freemarker instead of JSP - which if setup correctly, injects JSP tag access into Freemarker templates.

Alfresco does not use this approach - instead it calls the Freemarker engine directly and therefore JSP tags are not accessible.

Please see http://wiki.alfresco.com/wiki/Template_Guide#Methods (in particular the message() method which support I18N strings).

djimenez
Champ in-the-making
Champ in-the-making
Thank you. Now, I need to know How can I change the language (locale) through the webscript?

davidc
Star Contributor
Star Contributor
Do you mean you want to change the locale in the script itself, or for the web  script to execute in a locale specified in the request.

djimenez
Champ in-the-making
Champ in-the-making
Change the locale in the script itself.

Thank u.

davidc
Star Contributor
Star Contributor
I don't think we offer that right now.   What are you trying to achieve?  Perhaps there's another way.

djimenez
Champ in-the-making
Champ in-the-making
I try show the webscript in different languages, I see that with Java you can change the language with the setLocale and setContentLocale methods of the I18NUtil class. I like to know if the webscript will have something like this.

Thank u.

davidc
Star Contributor
Star Contributor
I still don't understand what you're trying to achieve.

In most cases, you should not need to change the locale during your output rendering.  Instead the output rendering just relies on the locale set elsewhere.

So, in a freemarker template you use the message(String) method - see http://wiki.alfresco.com/wiki/Template_Guide#Methods

If you execute your web script via the /wcservice url mapping, this should pick the locale of the web client user (i.e. the one they pick on the login screen).