cancel
Showing results for 
Search instead for 
Did you mean: 

MLtext within Javascript Webscript

guillaumefranco
Champ in-the-making
Champ in-the-making
Hello,

I'm trying to figure out how to set or select language used inside a JavaScript back-end Webscript

I'm currently setting title and description of a node

fileHandleFile.properties.title = titreHandleFile;
fileHandleFile.properties.description = descriptionHandleFile;
fileHandleFile.save();

but i can't manage to set the language used for this.

Moreover, if i use native web client interface (alfdicoms/faces/jsp/dialog/container.jsp) and set profile preference "Content Language Filter" to "French" I can read the new value but when i go back to "All Language"

so two questions :
1. How to set MLText lang at setting time inside a webscript ?
2. how to set MLText lange at reading time inside a webscript ?

If we must use it trough user profile preference, how can we change it trough Web Script ?

Regards
3 REPLIES 3

mrogers
Star Contributor
Star Contributor
Each webscript executes in a locale specified by the Accept Language http header.

You could change this by calling the Java API.
I18NUtil.setLocale

guillaumefranco
Champ in-the-making
Champ in-the-making
Ok for the Java API but I'm in a Javascript context so I can't simply put "I18NUtil.setLocale" into the js file.

Does Alfresco expose such functionality for Javascript Side or is it required to create a new BaseScopableProcessorExtension and would this work ?

Regards.

kevinr
Star Contributor
Star Contributor
Unfortunately changing the locale for MLText is not exposed via the JavaScript API. As the user in the post above mentions, the script executes with the locale as per the request for the webscript. Yes you could Spring in your own JavaScript root helper object to do this, or use a Java backed webscript.

Kev