Search This Blog

Tuesday, July 8, 2025

How Do I Specify the Primary Language for an Application in Oracle APEX

 

Introduction
Specifying the primary language for an application in Oracle APEX is the first step toward creating a globalized, multilingual experience. The primary language acts as the default for all application labels, messages, and user interface text when no other language preference is set. It also serves as the base language for translation files and determines how Oracle APEX handles text rendering and regional settings by default.

In Oracle APEX, specifying the primary language of your application is the foundational step for enabling multilingual support and regional formatting. The primary language acts as the default for all application interface elements, and it also becomes the source language when you export content for translation.

To define the primary language in Oracle APEX:

  1. Open Your Application
    From the APEX App Builder, open the application where you want to set the primary language.

  2. Navigate to Globalization Attributes
    Go to Shared Components > Globalization Attributes. This section controls how language and regional formatting are handled across the application.

  3. Set the Primary Language
    In the Globalization Attributes screen, locate the field labeled Primary Language. Select the appropriate language code from the list (e.g., en for English, fr for French, es for Spanish). This value tells APEX which language to use as the default when no other language is defined for the session or user.

  4. Select Language Source (Optional but Recommended)
    Below the primary language field is Application Language Derived From. This option determines how the application decides which language to use during a session. You can choose from:

    • Browser Language – Detects the browser’s default setting.

    • Application Item – Uses a page item (like P0_LANGUAGE) to control language, often from a language selector dropdown.

    • User Preference – Retrieves the language from a custom user profile.

    • Substitution String – Allows advanced or dynamic control.

    If you plan to let users change the language, it's best to use the Application Item option, then create a dynamic action or process to set the value of that item based on user input.

  5. Use with Language Translation
    Once the primary language is set, APEX uses this as the base for any translation you implement. When exporting XLIFF files to translate application content, the source text is assumed to be written in the primary language. This ensures consistency and accuracy when importing translated versions.

  6. Save and Apply Changes
    Click Apply Changes to confirm the configuration. APEX will now treat the selected language as the default for any session where no alternate language has been set.

  7. Test Your Setup
    Run the application and verify that all UI text appears in the correct default language. If you’ve enabled user-selected languages via an item, make sure switching values updates the application accordingly.

By specifying the primary language, Oracle APEX ensures consistent text rendering, predictable formatting for dates and numbers, and a reliable foundation for managing multilingual support. This setting is crucial when planning for translation, as it helps Oracle APEX understand how to process language switching and fallback behavior.

Oracle APEX supports multi-language applications through Globalization Attributes, which determine how the application’s text, date formats, and other language-dependent settings behave. One of the key aspects of globalization is specifying the Primary Language for an application.

Setting the correct Primary Language ensures that Oracle APEX properly handles text direction (left-to-right or right-to-left), language-specific messages, and translated content.

 

Steps to Specify the Primary Language in Oracle APEX

To define the Primary Language for your application, follow these steps:

  1. Open Your Application

    • Navigate to App Builder in Oracle APEX.

    • Select the application you want to modify.

  2. Access Globalization Attributes

    • Click on Shared Components.

    • Under the Globalization section, select Globalization Attributes.

  3. Set the Primary Language

    • Locate the Primary Language setting.

    • Choose the desired language from the dropdown list.

  4. Save the Changes

    • Click Apply Changes to save and apply the selected language to the application.

 

How the Primary Language Affects an APEX Application

When you specify a Primary Language, Oracle APEX:

  • Automatically determines the default language used for labels, messages, and UI components.

  • Adjusts the date and number formats based on language conventions.

  • Controls the text direction (left-to-right for English, French, etc.; right-to-left for Arabic, Hebrew, etc.).

  • Determines which translation files are used when running a translated version of the application.

 

Overriding the Primary Language at Runtime

Even after setting a Primary Language, APEX allows users to override this setting dynamically.

1. Using a URL Parameter

Users can change the application’s language by appending the p_lang parameter to the URL:

f?p=100:1:&SESSION.:LANG=en

This forces the application to display in English.

2. Using Application Computations

To dynamically set the language based on user preferences, create a Computation for the APP_USER_LANG substitution string:

  1. Go to Shared Components > Application Computations.

  2. Create a new computation for APP_USER_LANG.

  3. Use the following SQL to fetch the preferred language from a user profile table:

SELECT language_preference FROM user_settings WHERE user_id = :APP_USER;

  1. Set computation point to On New Session.

This ensures that each user gets their preferred language when they log in.

3. Using PL/SQL to Change Language

If you need to programmatically update the language setting, use:

BEGIN

    APEX_UTIL.SET_SESSION_LANG('fr');

END;

This will switch the session to French.

 

Best Practices for Setting the Primary Language

  • Choose a default language that matches your primary user base.

  • If supporting multiple languages, implement translation files (XLIFF).

  • Allow users to select their preferred language via session settings.

  • Use language-specific date and number formatting to ensure proper localization.

By properly configuring the Primary Language in Oracle APEX, you can create a more user-friendly and globally accessible application.

Conclusion
Setting the primary language in Oracle APEX provides a clear foundation for internationalizing your application. It ensures that all users see a consistent default language and allows you to build translation logic on top of a well-defined base. Whether you're targeting a single language audience or preparing for a multi-language rollout, correctly defining the primary language is an essential step in delivering a professional, localized application.

How Do I Implement Oracle APEX Globalization Codes in APEX

 

Introduction
Implementing Oracle APEX Globalization Codes in your application allows you to build solutions that automatically adapt to different languages, regions, and user preferences. These codes help control how text is translated, how dates and numbers are formatted, and how the interface adjusts for international users. By integrating globalization codes properly, you ensure that your application is user-friendly and culturally relevant no matter where your audience is located.

Implementing Oracle APEX globalization codes involves configuring your application to support multiple languages and regional settings. These globalization codes manage how your application behaves based on user preferences, browser settings, or explicit language selections. Oracle APEX includes built-in support for this through language definitions, application attributes, substitution strings, and session-level language controls.

Start by defining the primary language of your application. This is done in Shared Components > Globalization Attributes. Choose the default language (e.g., en, fr, de) that your app will use when no specific preference is set. Also, define how the language should be determined at runtime—via browser, application item, or user profile.

To enable multilingual support, go to Shared Components > Languages. Here, you can add other languages that your application should support. Each language is defined using a language code like es for Spanish or zh-cn for Simplified Chinese.

Once languages are configured, use substitution strings and text messages to manage content. Go to Shared Components > Text Messages, where you define messages with a unique name and specify translations for each language. For example:

  • Name: WELCOME_MSG

  • Language: en, Text: Welcome

  • Language: fr, Text: Bienvenue

  • Language: es, Text: Bienvenido

In your pages, reference the message using #WELCOME_MSG#, and APEX will automatically replace it with the correct translation based on the session language.

If your application includes translatable UI elements (page titles, region labels, button text), use the Translate Application feature. This generates an XLIFF file (XML Localization Interchange File Format) containing all UI text. Export the file, provide translations for each target language, and re-import it. Oracle APEX will handle language switching automatically when the session language changes.

To set the session language manually, you can use this PL/SQL in a Before Header process:

BEGIN
  APEX_UTIL.SET_SESSION_LANG('fr'); -- French
END;

Or, if using a language picker (like a select list), bind the value to an item (e.g., P0_LANGUAGE) and configure your globalization settings to derive the language from that item.

Date, time, number, and currency formats are also automatically managed based on the session's NLS (National Language Support) settings. These can be customized using PL/SQL:

BEGIN
  EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_DATE_FORMAT = ''DD.MM.YYYY''';
  EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_NUMERIC_CHARACTERS = '',.'''
END;

You can store language preferences per user in a custom user table and apply them when a user logs in:

DECLARE
  v_lang VARCHAR2(10);
BEGIN
  SELECT language_code INTO v_lang
  FROM app_users
  WHERE username = :APP_USER;

  APEX_UTIL.SET_SESSION_LANG(v_lang);
END;

By organizing your application this way, you can maintain one code base while delivering content in multiple languages and formats. Oracle APEX globalization codes make it easy to build international-ready applications that automatically adapt to the user's language and cultural expectations.

Implementing globalization codes properly ensures a smoother, more inclusive experience for all users, no matter where they are in the world.

Oracle APEX provides built-in globalization features that allow applications to support multiple languages, date formats, number formats, and other locale-specific settings. Understanding and correctly implementing globalization codes ensures that your APEX application adapts to different user regions and languages seamlessly.

Understanding Globalization Codes

Globalization codes in APEX are settings that control how an application behaves for users in different locations. These codes affect:

  • Language and translation settings

  • Date, time, and number formats

  • Currency display

  • Sorting and character sets

  • Session and database NLS (National Language Support) parameters

APEX automatically assigns globalization codes based on the application's Globalization settings. These can be overridden programmatically or adjusted per session.


Setting Globalization Codes in an APEX Application

Step 1: Configuring Globalization Settings at the Application Level

  1. Navigate to App Builder and open your application.

  2. Go to Shared Components.

  3. Under Globalization, select Globalization Attributes.

  4. Configure the following options: 

    • Primary Language: The default language of the application.

    • Application Language Derived From: Defines how the application determines the user's language. Options include: 

      • Session (derived from user session settings)

      • Browser Language (automatically detects based on the user’s browser)

      • Fixed Language (forces a specific language)

    • Date Format: Defines the default date format for users.

    • Number Format: Determines decimal and thousand separators.


Step 2: Using Globalization Codes in APEX

You can retrieve and set globalization codes dynamically within APEX.

Retrieve the Current Language

Use the following PL/SQL function to get the language code for the current user session:

SELECT APEX_UTIL.GET_SESSION_LANG FROM DUAL;

Alternatively, use LANG function:

SELECT APEX_LANG.LANG FROM DUAL;

Set the Language Dynamically

You can change the language setting for a user session by setting the language preference:

BEGIN

    APEX_UTIL.SET_SESSION_LANG('fr'); -- Set language to French

END;

This method allows users to switch languages dynamically without affecting the entire application.


Step 3: Implementing Translation for Multilingual Applications

Seeding Translations

If you want to support multiple languages, you must first generate a translatable version of your application using Seed Translations:

  1. Go to Shared ComponentsGlobalizationTranslate Application.

  2. Click Seed Translations to extract all translatable text.

  3. Download the XLIFF (XML Localization Interchange File Format) file.

  4. Provide the translated content and upload it back into APEX.

  5. Use Publish Application to apply the translations.

Applying Translations at Runtime

To ensure that the correct language is used based on the user's session or browser settings, check the language dynamically:

IF APEX_UTIL.GET_SESSION_LANG = 'es' THEN

    -- Apply Spanish settings

    APEX_LANG.MESSAGE('WELCOME_MESSAGE');

ELSE

    -- Apply English settings

    APEX_LANG.MESSAGE('WELCOME_MESSAGE');

END IF;


Step 4: Formatting Dates, Numbers, and Currency

Globalization settings also control how dates, numbers, and currency values appear.

Formatting Dates Based on User Locale

SELECT TO_CHAR(SYSDATE, APEX_UTIL.GET_SESSION_DATE_FORMAT) FROM DUAL;

Alternatively, use NLS_DATE_FORMAT for session-based formatting:

ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MM-YYYY';

Formatting Numbers

Ensure numbers are displayed correctly based on locale:

SELECT TO_CHAR(1234567.89, '999G999G999D99', 'NLS_NUMERIC_CHARACTERS='',.''') FROM DUAL;

Formatting Currency

To format currency based on the session locale:

SELECT TO_CHAR(1000, 'L999G999D99', 'NLS_CURRENCY=''€''') FROM DUAL;

This ensures that currency symbols and formatting are applied based on the user's region.


Step 5: Handling Right-to-Left (RTL) Languages

If your application supports languages like Arabic or Hebrew, you need to adjust styles to support Right-to-Left (RTL) layouts.

  1. In Shared Components, go to ThemesTheme Roller.

  2. Select Enable Right-to-Left Support.

  3. You can also apply CSS to modify directionality:

html[lang="ar"], html[lang="he"] {

    direction: rtl;

    text-align: right;

}


Step 6: Using Globalization in SQL Queries

To return results based on language settings, use language-dependent queries.

For example, to return translated content dynamically:

SELECT MESSAGE_TEXT 

FROM TRANSLATIONS_TABLE 

WHERE MESSAGE_ID = 'WELCOME_MESSAGE' 

AND LANGUAGE_CODE = APEX_UTIL.GET_SESSION_LANG;

This ensures that users see translated messages based on their session language.


Step 7: Debugging Globalization Issues

If you experience issues with globalization settings, use the APEX Debugging Tool to check the language and formatting settings in real time.

BEGIN

    APEX_DEBUG.MESSAGE('Current Language: ' || APEX_UTIL.GET_SESSION_LANG);

    APEX_DEBUG.MESSAGE('Current Date Format: ' || APEX_UTIL.GET_SESSION_DATE_FORMAT);

END;


Implementing Oracle APEX globalization codes ensures that your application can support multiple languages, number formats, and date formats dynamically. By configuring globalization attributes, seeding translations, applying language settings at runtime, and formatting content properly, you create a seamless user experience for a global audience.

This approach enhances usability, accessibility, and localization, making your APEX application adaptable to different cultural and regional preferences.


Conclusion
Using Oracle APEX Globalization Codes is an essential step in developing flexible, accessible, and globally ready applications. With careful configuration and use of built-in language tools and locale settings, you can create a seamless experience for users around the world. Whether you're targeting one region or many, APEX provides the framework to localize your application efficiently and effectively.

How Do I Make a Faceted Search Map Page in Oracle APEX

Combining faceted search with a map region in Oracle APEX enables users to filter data visually and spatially at the same time. This design ...