掲示板

i18n support in JSF Liferay 7

6年前 に Karel Bělunek によって更新されました。

i18n support in JSF Liferay 7

New Member 投稿: 8 参加年月日: 17/06/23 最新の投稿
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.
thumbnail
6年前 に Neil Griffin によって更新されました。

RE: i18n support in JSF Liferay 7 (回答)

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
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:
<repositories>
    <repository>
        <id>liferay-faces-snapshots</id>
        <name>Liferay Faces Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupid>com.liferay.faces</groupid>
        <artifactid>com.liferay.faces.bridge.ext</artifactid>
        <version>5.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupid>com.liferay.faces</groupid>
        <artifactid>com.liferay.faces.bridge.impl</artifactid>
        <version>4.1.0-SNAPSHOT</version>
        <!-- NOTE: This has a transitive dependency on com.liferay.faces.bridge.api-4.1.0-SNAPSHOT.jar -->
    </dependency>
    <dependency>
        <groupid>com.liferay.faces</groupid>
        <artifactid>com.liferay.faces.util</artifactid>
        <version>3.1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupid>com.liferay.faces</groupid>
        <artifactid>com.liferay.faces.portal</artifactid>
        <version>3.0.1-SNAPSHOT</version>
    </dependency>
</dependencies>


Kind Regards,

Neil
6年前 に Karel Bělunek によって更新されました。

RE: i18n support in JSF Liferay 7

New Member 投稿: 8 参加年月日: 17/06/23 最新の投稿
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.
thumbnail
6年前 に Neil Griffin によって更新されました。

RE: i18n support in JSF Liferay 7 (回答)

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
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:

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



Kind Regards,

Neil
6年前 に Karel Bělunek によって更新されました。

RE: i18n support in JSF Liferay 7

New Member 投稿: 8 参加年月日: 17/06/23 最新の投稿
Hi Neil,

The Map<String,Object> injection works correctly.

Thank you for the advice.

Kind regards

Karel B.
thumbnail
6年前 に Neil Griffin によって更新されました。

RE: i18n support in JSF Liferay 7

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Hi Karel,

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

Kind Regards,

Neil