Foros de discusión

Vaadin portlet language switch

thumbnail
Philippe Thibault, modificado hace 11 años.

Vaadin portlet language switch

Junior Member Mensajes: 46 Fecha de incorporación: 11/09/12 Mensajes recientes
Hi,

I'm currently implementing a portal with a bilingual french/english language switcher portlet that is embedded in the header section as to make it global. Everything works fine with Liferay's portlets, which is why I selected Liferay for my website actually emoticon

However I would like to create Vaadin portlet for forms and other dynamic web content presentation. While trying to learn Vaadin I had a hard time to find a simple internationalization solution. Is there a way to make a Vaadin portlet react to Liferay's language switcher portlet and translate its own content accordingly?

thanks for any help!

Philippe
thumbnail
David H Nebinger, modificado hace 11 años.

RE: Vaadin portlet language switch

Liferay Legend Mensajes: 14915 Fecha de incorporación: 2/09/06 Mensajes recientes
Unfortunately Vaadin does not know anything about the locale switching behind the scenes...

When you issue a call such as myButton.setCaption("caption"), the button actually gets "caption" as the string to use and does not do any message bundle lookups on it. So you've got to do the message bundle translation yourself, i.e. myButton.setCaption(LanguageUtil.get(locale, "caption")) sort of thing.

The important thing here is that you typically only call myButton.setCaption() during instantiation, so unless you are checking for locale changes and re-invoking myButton.setCaption() (amongst others) after a locale change, the user's change of locale will not be reflected in your Vaadin portlets until the user logs out and then back in.

It is possible to handle, but really depends upon how your project is coded (how you do navigation, etc.). You're left to do all of the heavy lifting yourself, but if you are starting from a blank slate and want to incorporate i18n support in, it is easier than trying to backfit it in after the fact.
thumbnail
Philippe Thibault, modificado hace 11 años.

RE: Vaadin portlet language switch

Junior Member Mensajes: 46 Fecha de incorporación: 11/09/12 Mensajes recientes
Thanks David for the info! I'm still having a hard time choosing between vaadin and alloy ui. Since I'm still at the beggining of my project I would very like not to regret it on the long run! What would be your choice of ui for new portlets that are linked with Liferay portal language facility : alloy ui or vaadin? BTW I'm using liferay 6.1.1-ce-ga2 on tomcat.

Vaadin looks appealing to me because it is pure Java and appears simple to learn and make dynamic content. However I understand that using the liferay portal language facility would be difficult.

AlloyUI looks more integrated with Liferay portal, however I'm having a hard time trying to learn how to use it in a new liferay portlet. I've looked into http://alloyui.com but I must say that the tutorial and examples there have left me dumbfounded ... is there a prerequisite to understand the documentation there? Why are they using the YUI object in examples and not AUI?

thanks for your help!

Philippe
thumbnail
David H Nebinger, modificado hace 11 años.

RE: Vaadin portlet language switch

Liferay Legend Mensajes: 14915 Fecha de incorporación: 2/09/06 Mensajes recientes
I recommend Vaadin for projects that do not require flashy eye candy (i.e. most enterprise portlets fall into this category) and teams that have strengths in Java but not so much in JS and/or front end technologies (jsp, jsf, etc.).

Vaadin will give you AJAX-based portlets that look clean and are highly responsive, but it is not the holy grail. You still need to handle i18n, navigation concepts, portlet mode switches, SB data mapping (Vaadin has a JPA-capable container, but no container for SB code so you're left to handling the retrieves, etc., yourself), Liferay vs Vaadin theming, ...

All that aside, with a little bit of pre-planning many of these issues can be dealt with and your focus can remain on building clean and functional portlets.

For the i18n stuff, I'd actually avoid trying to deal with in-flight locale switching. Most users will choose their locale once and rarely (if ever) change it again, so coding around what is likely an edge use case would not be the best use of your time and resources...
thumbnail
David H Nebinger, modificado hace 11 años.

RE: Vaadin portlet language switch

Liferay Legend Mensajes: 14915 Fecha de incorporación: 2/09/06 Mensajes recientes
Philippe Thibault:
AlloyUI looks more integrated with Liferay portal, however I'm having a hard time trying to learn how to use it in a new liferay portlet. I've looked into http://alloyui.com but I must say that the tutorial and examples there have left me dumbfounded ... is there a prerequisite to understand the documentation there? Why are they using the YUI object in examples and not AUI?


All of Liferay's portlets are based on AUI, so they are the best examples when it comes to learning AUI. Find an OOTB portlet which has functionality you're looking for, pull up the code and steal it...

The choice to create and use AUI in the portal was a good one, but it was clearly based on issues specific for Liferay and the portal environment. Unfortunately I don't think they 'sold' the concept to developers outside of Liferay very well, so as a project it didn't take off the way it was expected, which is unfortunate because it is a solid JS framework for using in the portal.

I think, as far as the examples go, they did a c-n-p from the YUI examples and just didn't change the references. AUI is based on YUI, so they are somewhat interchangeable from a core level, but AUI has the Liferay extensions for using in the portal...
thumbnail
Philippe Thibault, modificado hace 11 años.

RE: Vaadin portlet language switch

Junior Member Mensajes: 46 Fecha de incorporación: 11/09/12 Mensajes recientes
Thank you very much for all this info David!
gofri _, modificado hace 11 años.

RE: Vaadin portlet language switch

Junior Member Mensajes: 92 Fecha de incorporación: 2/03/07 Mensajes recientes
There are 2 parts of the question:
1. "translate its own content accordingly" - not directly related to Liferay, can be done as in any java application - ResourceBundle etc...
2. "Vaadin portlet react to Liferay's language switcher portlet" - what we're doing is following solution: implement custom PortletListener in vaadin portlet, that handles RenderRequest and receives locale from it. With this approach, changing languages in Liferay refreshes page (as usual) and vaadin portlet is refreshed with new locale.

Regarding Vaadin vs AlloyUI, I agree with David (well, after all his rank is Liferay Legend emoticon
Generally, we are using Alloy when we need more "web-like" solution. Alloy and Liferay tags are very helpful in jsps. Also as mentioned, a lot of existing reference portlets - for example, if we need something integrated with Web Content, Categories, Blogs etc.
Vaadin is very nice when building applications, that look and feel more "traditional" - custom navigation, a lot of form processing, reports etc.
Imho both frameworks are very useful, but for different type of tasks. If You really need to select only 1, go with Alloy - it is more universal. After some time, learn Vaadin and You will see that even not being so universal, for a lot of projects it is really very convenient.
thumbnail
Philippe Thibault, modificado hace 11 años.

RE: Vaadin portlet language switch

Junior Member Mensajes: 46 Fecha de incorporación: 11/09/12 Mensajes recientes
Thanks gofri for your thoughts on this! At least I see that passing the language switch event to vaadin might be easy. I think I will go for alloy to begin with the basic web component, even if I'm more confortable with java than javascript.
thumbnail
Jacques Traore, modificado hace 9 años.

RE: Vaadin portlet language switch

Junior Member Mensajes: 49 Fecha de incorporación: 21/01/13 Mensajes recientes
Hi Philippe,
I'm working on a bilingual website English/French. Everything is OK. The URL www.mysite.com goes to the English version and www.mysite.com/fr goes to the French one. We've created another domain named www.monsite.com which goes to the same IP as www.mysite.com (the En version) .
My need is that last one goes www.monsite.com/fr.
Is there a way to catch the caller URL inside LR, and redirect the user to the right version?
So, www.mysite.com opens the En version and www.monsite.com opens the french one (instead of typing www.monsite.com/fr).

Thank you in advance