How to do seed and publish for Oracle APEX translations using a simple SQL script

In the project that I work, the primary language for apex application is ‘en’ and there are 11 different languages it needs to be translated to. There have been many circumstances when there is a simple ‘process change’ in one of the page, I had to seed and publish all applications in the standard translation process even though there are no new translation strings need to be added/applied. I understand the need to seed the application first and then publish it but this is about 7 clicks once I start from ‘Shared components’ for each translated application. Even though there is no translation text/xliff file to be applied, I had to repeat this process 11 times (77 clicks) to get all functionality working for every language. I think, this calls for some enhancement.

Possibly,

1) on a single page provide a way for all applications to be seed and publish using a tabular form
2) even better, on the shared components page, provide a simple link to seed and publish all languages as there is no reason to even allow a user to choose which translated application need to be applied (we want all applications to work in the same way)

Until then, I wrote a simple script to make this work from a ‘sql’ script using one of Apex APIs – wwv_flow_translation_utilities

Following is a sample script that should do seed and publish in one go for all languages from sql plus. This made it so much easier and so far it has worked well.

set define off
set verify off
set serveroutput on size 1000000
set feedback off
WHENEVER SQLERROR EXIT SQL.SQLCODE ROLLBACK

--application/set_environment
prompt Seed and Publish application for all languages
begin
  dbms_output.put_line('setting the current schema to APEX_040000');
  execute immediate 'alter session set current_schema = APEX_040000';
end;
/

prompt Set Credentials...
begin
-- Assumes you are running the script connected to SQL*Plus as the Oracle user APEX_040000 or as the owner (parsing schema) of the application.
  wwv_flow_api.set_security_group_id(p_security_group_id => nvl(wwv_flow_application_install.get_workspace_id,114400445500724));
end;
/

prompt ..running seed and publish
declare
  l_sgid number := 114400445500724;
  l_primary_language_flow_id number := 100;
begin
  for c in (
            select translation_flow_id, translation_flow_language_code
              from wwv_flow_language_map
             where security_group_id = l_sgid
               and primary_language_flow_id = l_primary_language_flow_id
             order by 1
           )
 loop
   -- set security group ID
   wwv_flow_security.g_security_group_id := l_sgid;
   
   wwv_flow_translation_utilities.seed_and_publish
   (
     p_from_flow_id       => l_primary_language_flow_id,
     p_language           => c.translation_flow_language_code,
     p_insert_only        => 'NO',
     p_translated_flow_id => c.translation_flow_id,
     p_security_group_id  => l_sgid
   );
   commit;
 end loop;

end;
/
set verify on
set feedback on
prompt ..Completed successfully

This takes some time to seed and publish for all languages but every time it had worked successfully.

4 thoughts on “How to do seed and publish for Oracle APEX translations using a simple SQL script

  1. If you are looking for translations for various languages checkout:
    http://translate-apex.com
    It’s an Oracle Apex community effort to translate the platform to all languages it’s used in and to do so in a standardized, reproducible approach. There are translations in almost 32 languages (10 built ones, extracted for easier management and 22 provided by community, e.g.: Dutch, Croatian, Arabic, Polish and more).
    If you have custom translations that you would like to provide then do so and grow the community!

    regards,
    Maciej

  2. Hi,

    Very well written and is useful. Please can you tell me where can i get hardcoded “114400445500724” in my application dynamically? Thanks a lot.

    Warm Regards,
    Sunil Bhatia

    • Sunil, Thanks!

      There are few ways to get the security_group_id, the documented way is below:

      l_sgid := apex_util.find_security_group_id (p_workspace = 'TMM');
      

      Here ‘TMM’ is my workspace name. You need to replace with your workspace name where the application is created under.

      APEX documentation link here.

Leave a reply to taj-ud-din Cancel reply