Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Karel Bělunek
i18n support in JSF Liferay 7
July 24, 2017 4:21 AM
Answer

Karel Bělunek

Rank: New Member

Posts: 8

Join Date: June 23, 2017

Recent Posts

I have fond a problem with internationalisation in Liferay Faces in Liferay 7 ga4

I did not found any Liferay 7 related i18n documentation and when I followed 6.2 documentation (https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/localizing-jsf-portlets) - it behaves strange.

I attached simple example - Primefaces module by liferayfaces.org maven generetor and I added locale-config into faces-config.xml.

The result is, that JSF portlet ignores language setting set by Liferay language selector and uses one of alternative langueges (czech).
Also the czech message ifs malformed, it looks that the portlet does not use UTF-8 form displaying characters with accents.

Souce code anf few screensthots are attached.

What is the correct way to use liferay intenationalization is JSF environment?

Regards

Karel B.
Attachment

Attachment

Attachment

Attachments: CS_selected.png (41.5k), EN_selected.png (32.6k), ES_selected.png (42.2k), com.mycompany.my.primefaces.portlet.zip (19.5k)
Neil Griffin
RE: i18n support in JSF Liferay 7
July 24, 2017 9:40 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2499

Join Date: July 26, 2005

Recent Posts

Hi Karel,

Thanks for posting your question and for providing a good reproducer portlet. You might be encountering FACES-2996. Please try our latest SNAPSHOT dependencies and see if the problem goes away:
 1<repositories>
 2    <repository>
 3        <id>liferay-faces-snapshots</id>
 4        <name>Liferay Faces Snapshots</name>
 5        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
 6        <releases>
 7            <enabled>false</enabled>
 8        </releases>
 9        <snapshots>
10            <enabled>true</enabled>
11        </snapshots>
12    </repository>
13</repositories>
14
15<dependencies>
16    <dependency>
17        <groupId>com.liferay.faces</groupId>
18        <artifactId>com.liferay.faces.bridge.ext</artifactId>
19        <version>5.0.1-SNAPSHOT</version>
20    </dependency>
21    <dependency>
22        <groupId>com.liferay.faces</groupId>
23        <artifactId>com.liferay.faces.bridge.impl</artifactId>
24        <version>4.1.0-SNAPSHOT</version>
25        <!-- NOTE: This has a transitive dependency on com.liferay.faces.bridge.api-4.1.0-SNAPSHOT.jar -->
26    </dependency>
27    <dependency>
28        <groupId>com.liferay.faces</groupId>
29        <artifactId>com.liferay.faces.util</artifactId>
30        <version>3.1.0-SNAPSHOT</version>
31    </dependency>
32    <dependency>
33        <groupId>com.liferay.faces</groupId>
34        <artifactId>com.liferay.faces.portal</artifactId>
35        <version>3.0.1-SNAPSHOT</version>
36    </dependency>
37</dependencies>


Kind Regards,

Neil
Karel Bělunek
RE: i18n support in JSF Liferay 7
July 26, 2017 3:15 AM
Answer

Karel Bělunek

Rank: New Member

Posts: 8

Join Date: June 23, 2017

Recent Posts

Hi Neil,

the snapshot version works corectly, thank you very much!

Please, what is the current roadmap for release of the fixed version?

An I have, please, additional question.
Standard way how to access ResourceBundle from JSF backing bean is:

@ManagedProperty("#{i18n}")
private ResourceBundle text;


This approach does not work because injected object is of type com.liferay.faces.util.el.internal.I18nMap, so I changed definition to
@ManagedProperty("#{i18n}")
private I18nMap text;


an I am accessing keys using: text.get("com.mycompany.my.primefaces.portlet-hello-world").toString();

Everything works but the I18nMap object belongs to package com.liferay.faces.util.el.internal - this "internal" worries me.

Is my approach for loading keys correct? I am trying to prevent usage of some internal stuff that is not intended to be used as an API.

Kind regards

Karel B.
Neil Griffin
RE: i18n support in JSF Liferay 7
July 27, 2017 8:27 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2499

Join Date: July 26, 2005

Recent Posts

Hi Karel,

I'm glad that the snapshot versions are working well for you. The Liferay Faces team is currently in a bugfix sprint working towards our next release, which is planned for August.

Regarding i18n, it is good that the sub-package "internal" became a cause for your concern. Everything under "internal" sub-packages is not API (an implementation detail) and subject to change at any time.

For the injection type, you can use Map<String, Object> instead of the internal implementation type. Alternatively you could access the I18n factory:

1FacesContext facesContext = FacesContext.getCurrentInstance();
2ExternalContext externalContext = facesContext.getExternalContext();
3I18n i18n = I18nFactory.getI18nInstance(externalContext);



Kind Regards,

Neil
Karel Bělunek
RE: i18n support in JSF Liferay 7
July 28, 2017 7:42 AM
Answer

Karel Bělunek

Rank: New Member

Posts: 8

Join Date: June 23, 2017

Recent Posts

Hi Neil,

The Map<String,Object> injection works correctly.

Thank you for the advice.

Kind regards

Karel B.
Neil Griffin
RE: i18n support in JSF Liferay 7
July 28, 2017 7:51 AM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2499

Join Date: July 26, 2005

Recent Posts

Hi Karel,

I'm glad to know that it is working for you now, and thanks for using Liferay Faces! emoticon

Kind Regards,

Neil