Reputation: 413
I have a page template that in webcenter portal with footer with 2 output text which will be rendered depending on the selected language from the language task flow.
I have custom template which I've created with the jdeveloper and had put the follwing output label:
<af:outputFormatted id ="copyright" rendered="# {facesContext.externalContext.requestLocale} eq 'en'" value="the english text" />
<af:outputFormatted id ="copyright" rendered="#{facesContext.externalContext.requestLocale} eq 'ar'" value="the arabic text" />
And this El expression always return false so how to render this components depending on the selected language?
Upvotes: 0
Views: 396
Reputation: 977
The issue is that you are closing your el expression too soon ("requestLocale }") . To fix it, replace :
<af:outputFormatted id="copyright" rendered="#{facesContext.externalContext.requestLocale} eq 'en'" value="the english text" />
by
<af:outputFormatted id="copyright" rendered="#{facesContext.externalContext.requestLocale eq 'en'}" value="the english text" />
Or, as an alternative solution, you can have only one outputFormatted with all values like this :
<af:outputFormatted id="copyright" value="#{facesContext.externalContext.requestLocale eq 'en' ? 'the english text':(facesContext.externalContext.requestLocale eq 'ar' ? 'the arabic text' : 'Default text')}" />
However if you are looking for a translation functionnality in ADF you should go for a translation bundle file as explain in the documentation here : https://docs.oracle.com/cd/E15051_01/web.1111/b31973/af_global.htm#ADFUI425
Internationalization is the process of designing and developing products for easy adaptation to specific local languages and cultures. Localization is the process of adapting a product for a specific local language or culture by translating text and adding locale-specific components. A successfully localized application will appear to have been developed within the local culture. JDeveloper supports easy localization of ADF Faces components using the abstract class java.util.ResourceBundle to provide locale-specific resources.
When your application will be viewed by users in more than one country, you can configure your JSF page or application to use different locales so that it displays the correct language for the language setting of a user's browser. For example, if you know your page will be viewed in Italy, you can localize your page so that when a user's browser is set to use the Italian language, text strings in the browser page will appear in Italian.
ADF Faces components may include text that is part of the component, for example the af:table component uses the resource string af_table.LABEL_FETCHING for the message text that is displayed in the browser while the table is fetching data during the initial load of data or while the table is being scrolled. JDeveloper provides automatic translation of these text resources into 28 languages. These text resources are referenced in a resource bundle. If you set the browser to use the language in Italy, any text contained within the components will automatically be displayed in Italian. For more information on skins and resource bundles, see Chapter 20, "Customizing the Appearance Using Styles and Skins".
For any text you add to a component, for example if you define the label of an af:commandButton component by setting the text attribute, you must provide a resource bundle that holds the actual text, create a version of the resource bundle for each locale, and add a element to define default and support locales in the application's faces-config.xml file. You must also add a element to your application's faces-config.xml file in order to make the resource bundles available to all the pages in your application. Once you have configured and registered a resource bundle, the Expression Language (EL) editor will display the key from the bundle, making it easier to reference the bundle in application pages.
To simplify the process of creating text resources for text you add to ADF components, JDeveloper supports automatic resource bundle synchronization for any translatable string in the visual editor. When you edit components directly in the visual editor or in the Property Inspector, text resources are automatically created in the base resource bundle.
Upvotes: 0