Wednesday, January 16, 2013

Oracle APEX Translations

This post may not be ideal under Oracle Apps blog but sometimes you can't stop working on associated technologies especially when doing technical consulting work.

I explored Oracle APEX product during Redhat Assignment for Supportable 360 application 

Steps used for APEX translated application access to users

APEX translated application Language Drop down.

Requirement is to have languages drop down close to navigation bar so user can select language of choice and should be available for next user visit.

0) These steps assumes XLIFF files and application mappings are in place and working correctly Application Express 4.2.0.00.27

1) Define shared component - User Interface - list of values P_LANGUAGE -- add static values as Deutsch and return value 1::LANG:NO::FSP_LANGUAGE_PREFERENCE:de
for each language applicable. Total 10 entries should be there

2) Define shared component - Logic - application item - FSP_LANGUAGE_PREFERENCE  and RH_APEX_LANG_URL

   application processes
   i)   p_set_apex_lang_url , sequence 1 ,
        Process Point "On Load: Before Header(page template header)
      
       BEGIN
          :RH_APEX_LANG_URL:=fnd_profile.value('FND_APEX_URL')||'f?p=&APP_ID.:1' ;
       END;

  ii) set_language , sequence 1 ,
      Process Point "On Load: Before Header(page template header)
      begin
           owa_util.redirect_url('f?p='||:APP_ID||':'||:APP_PAGE_ID||':'||:APP_SESSION);
     end;

   Process Error Message :  "Process cannot be executed"
   Condition Type : "Request = Expression 1"
   Expression 1 : "LANG"
     
  iii) p_set_user_lang_preference sequence 2 ,
      Process Point "On Load: Before Header(page template  header)
 
   BEGIN
     IF :FSP_LANGUAGE_PREFERENCE  IS NOT NULL THEN
       APEX_UTIL.SET_PREFERENCE (
                   p_preference => 'FSP_LANGUAGE_PREFERENCE',
                   p_value => :FSP_LANGUAGE_PREFERENCE );
    END IF;
  END;

This ensures that user preference is stored for future references and every time when user opens Supportable 360 last language is used

 iv) Create Shared Component --> Logic --> Application Computations
   Sequence 10 , Name RH_APEX_LANG_URL , Point "On New Instance (new session)"  Type : "SQL Query (return single value)"

Computation: " select fnd_profile.value('FND_APEX_URL')||'f?p=&APP_ID.:1' from dual "

Note : FND_APEX_URL is profile option value set in sourcing Oracle Applications


3) Set Shared Componenet --> Globalization --> globalization attributes
   Application Language Derived From : Application Preference (use FSP_LANGUAGE_PREFERENCE )

4) On page 0 define html region called P_LANGUAGE_SELECTOR ,  type "HTML Text" Display Point "Page Template Region Position 8"
Start on new Row "Yes", column/ coloumn span automatic  , Region Display Selector "No"

5) Define page item P0_PICK_LANG inside above region
Display as "Select List" , start on new row "Yes" , column/ coloumn span automatic ,
Page action when value changed "Redirect to page (based on selected value)
Named LOV "P_LANGUAGE" , HTML Form Element attributes style ="height:22px;width:115px;vertical-align:top;" Display Extra Values : "Yes" , Display null value: "Yes"

Default value

case
when lower(APEX_UTIL.GET_PREFERENCE (p_preference => 'FSP_LANGUAGE_PREFERENCE',p_user => APEX_CUSTOM_AUTH.GET_USER ))= 'en' then 'English'
when lower(APEX_UTIL.GET_PREFERENCE (p_preference => 'FSP_LANGUAGE_PREFERENCE',p_user => APEX_CUSTOM_AUTH.GET_USER ))= 'de' then 'Deutsch'
when lower(APEX_UTIL.GET_PREFERENCE (p_preference => 'FSP_LANGUAGE_PREFERENCE',p_user => APEX_CUSTOM_AUTH.GET_USER ))= 'es' then 'Español'
when lower(APEX_UTIL.GET_PREFERENCE (p_preference => 'FSP_LANGUAGE_PREFERENCE',p_user => APEX_CUSTOM_AUTH.GET_USER ))= 'fr' then 'Français'
when lower(APEX_UTIL.GET_PREFERENCE (p_preference => 'FSP_LANGUAGE_PREFERENCE',p_user => APEX_CUSTOM_AUTH.GET_USER ))= 'it' then 'Italiano'
when lower(APEX_UTIL.GET_PREFERENCE (p_preference => 'FSP_LANGUAGE_PREFERENCE',p_user => APEX_CUSTOM_AUTH.GET_USER ))= 'pt-br' then 'Português(Br)'
when lower(APEX_UTIL.GET_PREFERENCE (p_preference => 'FSP_LANGUAGE_PREFERENCE',p_user => APEX_CUSTOM_AUTH.GET_USER ))= 'zh-tw' then '中文 (繁體)'
when lower(APEX_UTIL.GET_PREFERENCE (p_preference => 'FSP_LANGUAGE_PREFERENCE',p_user => APEX_CUSTOM_AUTH.GET_USER ))= 'zh-cn' then '中文(简体)'
when lower(APEX_UTIL.GET_PREFERENCE (p_preference => 'FSP_LANGUAGE_PREFERENCE',p_user => APEX_CUSTOM_AUTH.GET_USER ))= 'ja' then '日本語'
when lower(APEX_UTIL.GET_PREFERENCE (p_preference => 'FSP_LANGUAGE_PREFERENCE',p_user => APEX_CUSTOM_AUTH.GET_USER ))= 'ko' then '한국어'
end

Default Value type : PL/SQL Expression


6) Modify Page theme for 9 Simple Gray
Theme Name : One Level Tabs - Right Sidebar (optional / table-based)

add below code in Definition --> Body section.
This format's positioning by using HTML attributes defined here.
 I have used display point #REGION_POSITION_08# for language drop down


<div id="header">
  <div id="app-logo"><a href="#HOME_LINK#">#LOGO##REGION_POSITION_06#</a></div>
  #REGION_POSITION_07#
  <div style="width:600px;vertical-align:top;" id="navbar">
   <div class="app-user">#REGION_POSITION_08#</div>
     #NAVIGATION_BAR#
   <div class="app-user">#WELCOME_USER#</div>   
  </div>


Need more details ?  Please refer Oracle APEX 4.0 Cookbook .