[ 
http://jira.nuxeo.org/browse/NXP-3952?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=57847#action_57847
 ] 

Alexandre Russel commented on NXP-3952:
---------------------------------------

* webwidget internationalisation:
** webwidget in Nuxeo
 A webwidget is a snippet of html, fetch via javascript to be shown on a page 
usually a
 dashboard. In Nuxeo we create the html file and contribute it via an extension 
point. The
decoration of the widget is also contributed by an extension point.
** how to i10nalise webwidget
We could use a freemarker template instead of html, the problem with this 
solution is that we
need to compute the webwidget each time a request is made, we can't cache it.

We plan to follow netvibes way of internationalization:
http://dev.netvibes.com/doc/uwa/howto/localize_widget?s[]=language
It could works with our netvibe webwidget, but can also be used by any 
javascript code on the page.
The running javascript know the local and call the server for the internalized 
file:
var YourWidgetName = {};
YourWidgetName.l10n = new Array();

YourWidgetName.getl10n = function () {
  UWA.Data.request(
    'http://api.example.org/l10n.php?lang=' + widget.lang,
      {
      method: 'get',
      proxy: 'ajax',
      type: 'json',
      cache: 1,
      onComplete: YourWidgetName.processl10n
      }
    );
  }

On server side our restlet:
- find the language
- find the messages_*.properties
- create a json file
- cache the file
- return the file

The messages are now available via _('myMessageKey')
The change we can do to the netvibe way is to fetch the file on load in the 
include.xhtml so one call
is done for all widgets and accessible to all js.

Widget comes with an easy way to set some values:
YourWidgetName.processl10n = function(loc) {
  YourWidgetName.l10n = loc;
  widget.setTitle(YourWidgetName.l10n.widgetTitle);
}

things to do:
* check if you should use a file name message_fr instead of using a param 
lang=fr (caching with browser might be better)
*  check if we can use resource servlet from WebEngine





> add the possibility to internationalise webwidget
> -------------------------------------------------
>
>                 Key: NXP-3952
>                 URL: http://jira.nuxeo.org/browse/NXP-3952
>             Project: Nuxeo Enterprise Platform
>          Issue Type: Improvement
>    Affects Versions: 5.2 GA
>            Reporter: Alexandre Russel
>            Assignee: Thierry Delprat
>             Fix For: 5.2.1
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.nuxeo.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
ECM-tickets mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm-tickets

Reply via email to