Tuesday, June 06, 2006

Translation in APEX - Mini how-to

Hi all,

I will try to give You my example of solving translation of application in APEX.

Main parameters:
Primary language: en (English)
Translation lang: hr (Croatian).

Read more


1.Firstly you have to define primary language (Application Builder>Application 500>Edit Globalization Attributes) and select your primary language (Application Primary Language: English (en).
2. On the sam page define Application Language Derived From as "Application preference (use FSP_LANGUAGE_PREFERENCE).
3. Define translation mapping "Application Builder>Application 500>Shared Components>Translate Application>Application Language Mappings" and create mappings for your second language (example is hr (Croatian)).
4. On the login page or first page if you don't have login, create hidden field (P101_LANG i n my example replace for your usage). It is used for rememebering current language
5. Create new application process (Application Builder>Application 500>Shared Components>Application Processes)
Name: redirect
Process point: On load before header
Type: PL/SQL Anonymous block
Conditions>condition type: Request=Expression1
Conditions>Expression1: LANG
Process text (here is the code):
BEGIN
IF nvl(:P101_LANG,'en')='hr' THEN
:P101_LANG:='en';
ELSE
:P101_LANG:='hr';
END IF;
HTMLDB_UTIL.SET_PREFERENCE ('FSP_LANGUAGE_PREFERENCE',:P101_LANG,:FLOW_USER);
owa_util.redirect_url('f?p='||:APP_ID||':'||:APP_PAGE_ID||':'||:SESSION);
END;

6. Login page: on this page create one button with label in your primary lang. point on second language. My example label is "Croatian" in english as primary language and translated to "English" in Croatian. This logic is used for having just one button saying "Croatian" when I'm in english web page and "English" when I'm in croatian web page.
Button has "Optional URL Redirect" with :
Target is: page in this application
Page : your login page number (most probably 101)
Request: LANG

7. For all other pages i use new item on navigation bar defined as:
Label: Croatian (secondary language) in Croatian translation label is "English"
Target>Target Type: Page in this application
Target>Page: &APP_PAGE_ID. (don't forget dot on the end)
Target>Request: LANG

8. Export XLIFF
9. Translate
10. Import translation
11. Publish translated app
12. Enjoy
That's all folks.

Main logic is to create same process for every page that is triggered if the request is LANG. This process changes the FSP_LANGUAGE_PREFERENCE preference that as far as I know can not be changed as other common app parameter but using HTMLDB_UTIL.SET_PREFERENCE function. With hte process in place you just have to implement link on every page for itself with request=lang and tha language will change.

I hope this is useful for everybody because it took me 6 bloody hours to do figure it out.

Published on Oracle forum by Dark Lord

3 comments:

Anonymous said...

Hello,

thanks for sharing your experience with us.
but can you please be more detailed.
i got really dizzy starting point 6.
can you please describe every detail.

10x in advance!!
regards,

Anonymous said...

I am changing the poperty FSP_APPLICATION_LANGUAGE succesfully with the help of the navigation bar entries. But owa_util.redirect doesnt work. I have to submit the page after the navigation bat entry click. How do i submit automatically by just pressing navigation entries.

Thank you.

Unknown said...

Thanks for the simplified tutorial. I managed everything described but 2 things ->

Should the published applications be listed in my Application Builder? They're not.

Does anybody else have problems where their authentication schemes are not copied with the published app? I can't use any page.

Thanks