Dienstag, 11. Januar 2022

Automatically publish translations after changes in an APEX app

Seed & Publish Translations Plug-In

There is a little annoyance that you encounter when you develop multilingual APEX apps. When your primary language is English and the current session language is different for example German, then changes in your applications will not be displayed in that session, because APEX continues to display an older version that you have published earlier. Even when the change is invisible program logic it will be ignored.

A required task for APEX developers is: When any modification is made to your primary application, perform the "Seed" and "Publish" operations to recreate an updated version of your translated application(s). I had to repeat this task dozens of times by tweaking the layout for a second language.

You have to seed and publish the translations to see the change in your translated session. Since APEX provides API functions for the seeding and publishing of translations and metadata about the last publishing date can be retrieved from a view, this can be automated with an APEX processing Plug-In. While implementing the plug-in I copied a solution for the Data Browser App that can publish the translated apps in a background process. When you run the API calls as described in the APEX API Reference book by setting the environment with apex_util.set_security_group_id you can run the apex_lang.seed_translations and apex_lang.publish_application inside a procedure that is called in a scheduler job. When the procedure is defined with AUTHID DEFINER, then the scheduler jobs are enabled to find the translations. But when you execute this in an anonymous code block, then the call to apex_util.set_security_group_id has to be replaced by a call to apex_session.attach to enable the apex_lang API calls.

This Plug-In keeps the translated applications up-to-date automatically by seeding and publishing the running application with an asynchronous background job.

The Plug-In solves the following problems:

  1. When you develop multilingual APEX applications, you have to repeat the "Seed" and "Publish" operations as often as you make any changes. For example: When your application's primary language is English and you inspect the german version of your app you may find issues with truncated labels because of the space for much longer item labels. When you change the "Column Span" of an item you have to repeat the publish translations operation to see the result of your change in the german app.
  2. When you install multilingual APEX applications on a different website via the import application process, you have to manually perform the publish operation to see the translated version of your app.
  3. You have to wait many seconds until the "Seed" and "Publish" operations are completed before you can continue with your work.

The Plug-In process performs the following steps:

  • Retrieve the last updated date of the application.
  • Retrieve the value of a preference variable PUBLISH_TRANSLATIONSXX where XX is the application id.
  • Compares the last updated date with the preference variable and quit when the values are equal.
  • Store the last updated date in the preference variable.
  • Create a small script to seed & publish the app in all supported languages.
  • Execute the script immediately or asynchronous.
See the GitHub repository for more details:

A simple Demo App is provided in the repository and runs at:

Keine Kommentare:

Kommentar veröffentlichen

Hinweis: Nur ein Mitglied dieses Blogs kann Kommentare posten.