APEX Application Language Derived From Should be "Session"

The Challenge of Language Selection

APEX applications are pretty easy to translate into other languages. Under Shared Components > Globalization, you define the languages you want, seed the repository, export an LDIF file, get it translated, reload it, publish the application. OK, that's a lot of work, but there is another challenge. APEX provides many (in my mind, too many) options for identifying what language the user wants to see the application in. In the Application Definition > Globalization you select "Application Language Derived From". Here is the TLDR. Always choose "Session."

Session Advantages

By leveraging Session, we can achieve the best of all of the other options. Here's a breakdown of the benefits it offers:

  1. Automatic Browser Language Detection: Session enables Apex applications to detect the user's browser language automatically. This ensures that users are presented with content in their preferred language from the moment they access the application. It requires a little work, but it's still pretty easy.

  2. Manual Language Switching: Session also allows users to manually switch between different languages. This feature caters to users who may prefer a language other than their browser's default setting.

  3. Persistent User Language Preferences: For logged-in users, Session enables the application to save and remember their language preferences. This ensures a personalized experience, as users won't have to manually switch languages every time they access the application.

Some of the features above look like they would be taken care of by other options. While that is true, the other options each only have one of these features and can't be made to have all of them.

In short, "Session" allows you to use apex_util.get_session_lang and apex_util.set_session_lang . This allows you to set and get the session in any way you want--you have complete control.

Implementation Steps

We've made it easy to do all of these in your Apex application. You can follow along in APEX Instant Tips #53.

All of the code you need is here:
https://github.com/insum-labs/translate-apex

Follow these steps in your application:

  1. Globalization Settings: In the Apex application's Globalization Settings, set the "Application Language Derived From" option to "Session." This ensures that the application takes language preferences from the session.

  2. Handling Public Pages: On public pages, it's crucial to reload the page if the session language is null with a before header branch. This is Step 2 in the code link above.

  3. Language Preferences After Authentication: After authentication, run the same procedure to capture and set the user's language preference based on their browser language and any manual changes they make. This is Step 3 in the code link below.

  4. Handling Language Preferences: Provide users with an interface to change their language preferences. This can be achieved by adding a language selection option, such as a dropdown or radio group, and saving the selected language as the user's preference using Apex. This is Step 4 in the code link above.

You can see it in action at APEX Instant Tips #53.