Saturday, 6 October 2018

Create Multilingual Application in Oracle APEX

Multilingual Application in Oracle APEX


This article should give you an overview and a brief understanding of translating Oracle APEX applications into multiple languages.
Application Express offers built-in functionality to develop the multilingual application without needing to create another application. 

As a part of the demonstration, we will need a simple application with English as the Application Primary Language. Once we have an application in our disposal follow below steps.

Step 1: 

Navigate to Shared Components -> Application Definition Attributes -> Globalization 

Set the Application Language Derived From to "Item Preference (use item containing preference)"



  • Item Preference (use item containing preference) - Determines the translated application language based on an application-level item called FSP_LANGUAGE_PREFERENCE Using this option requires Application Express to determine the appropriate language preference every time the user logs in.

Step 2:

FSP_LANGUAGE_PREFERENCE is an Application Item which the developer has to create to help APEX to determine the language the User prefer every time he logs in.

In order to create the Application Item navigate to Shared Components -> Application Items and Click on Create button

For this demo leave all other fields be their default values.


Step 3:

Creating XLIFF Files

XLIFF is the abbreviation for XML Localization Interchange File Format and it is one of the world's most recognized standards in localization. It specifies the elements and attributes to store content extracted from various original file formats and its corresponding translation.

XLIFF format has been adopted by APEX as the format in the localization process.


To create an XLIFF file Navigate to Shared Components -> Globalization -> Translate Application

In this window, you can see the list of steps necessary to fully translate the application in APEX. Let us call this Translation Homepage.



Click on the first step Define application languages and then click on the Create button.

In the create wizard, enter an application id which is not created in this APEX environment and select the language that you want to translate to. I am selecting German De. Then click on the Create button


Once a shadow translation application is created, return back to the Translation Homepage. Click on the second step in the list Seed translatable text.


Select the previously created shadow application and then Seed. Doing so creates entries in the APEX repository for every translatable text available in the application. This entries later will be used to generate the XLIFF file.


Once seeding is completed, return back to the Translation Homepage. Click on the third step in the list Download XLIFF translation files



Select the language (De in my example) and click on Export XLIFF File for Application

Note: We are exporting all the translatable elements since we are exporting the application for the first time. 

Open the downloaded XLIFF file which looks similar to the pic below. The highlighted target tags should be translated accordingly to the required language (In the pic I have not translated the highlighted text but you should).



Save the XLIFF file after translating the texts, return back to the Translation Homepage. Click on the fifth step in the list Apply XLIFF translation files.

Upload the XLIFF file by clicking on the Upload button.


In the next screen, as shown above, select the translation mapping to apply the XLIFF file.

Then, select the row with the checkbox on the right and click on Apply Checked button

Once the above step is done follow the same except for this time click on the Publish button.

So we are completed with the translation of the application.

Step 4:

Create an application process (Shared Components -> Application Process)

Name: Set Language
Point: On Load Before Header (page template header)



Source:

begin
owa_util.redirect_url('f?p='||:APP_ID||':'||:APP_PAGE_ID||':'||:APP_SESSION);
end;

Condition Type: Request = Expression 1

Expression: LANG

Step 5:

Now the final step is the switching languages. To accomplish that we would create entries in the navigation bar. (Shared Components -> Navigation -> Navigation Bar list)

Select the Navigation Bar list and create entries (2 entries in my case for each language) 

List Entry Label: English or German


Edit: Page should be &APP_PAGE_ID. in the above pic





Step 6:

Please repeat the process of seeding, exporting, translating and importing. This step has to be done every-time any change is performed on the application.









Note: This above example works only if you do not have page level protection on URL in your application.


I will be posting alternate ways in somedays.






2 comments:

  1. Thanks for this valuable post, I implemented correctly for these languages (Hindi, Arabic and Urdu), but I m facing following two issues:

    1) not all languages are showing on the login page
    2) need to select language twice from the navigation bar list, no page direction and content changed in the one-time selection, although i have seen URL changed including language selection once i select the language from the navigation bar list but after this, i need to select same language for the desired result.

    Please guide me here if you can… Thanks in advance

    ReplyDelete
  2. @Tanveer Ali, owa_util.redirect() is no longer working. Look at this youtube video for a working solution, https://www.youtube.com/watch?v=2gup2RQH8L8.

    ReplyDelete