| Last Update: | Jul 28, 2003 |
| Status: | Production |
| Version: | Any PDK Release |
Oracle Portal provides a robust set of APIs for storing and retrieving of strings in different languages in your PL/SQL portlets. For an introductory overview of NLS Services, please refer to the Primer on using National Language Support.
NLS services are available through the wwnls_api package.
This article describes how the NLS services are implemented using the Services Example. It provides a guideline for adding the NLS service to your portlet functionality.The general model for working with the NLS service can be described as follows:
set serveroutput on size 1000000
set define off
declare
l_string_id integer;
...
begin
dbms_output.put_line('Adding NLS strings...');
-- strings for portlet record fields --
l_string_id := wwnls_api.add_string( 'provider','services','ptldefname','us', 'Apply ');
wwnls_api.set_string( 'provider','services','ptldefname','d', 'HELLOWORLDPORTLET');
/
l_string_id := wwnls_api.add_string( 'provider','services','ptldefdesc','us', 'OK');
wwnls_api.set_string( 'provider','services','ptldefdesc','d', 'Hello World Portlet with NLS');
l_string_id := wwnls_api.add_string( 'provider','services','ptldeftitle','us', 'Cancel');
wwnls_api.set_string( 'provider','services','ptldeftitle','d', 'Hello World Portlet with NLS');
...
commit;
exception
when others then
dbms_output.put_line('ERROR: Could not install seed data');
rollback;
end;
On similar lines you can create your own loading script to seed the strings your portlet requires. This may include strings required by each show mode as well as strings required for error messages.
CREATE OR REPLACE
package body SERVICES_PORTLET
is
-- Constants --
DOMAIN constant varchar2(30) := 'provider';
SUBDOMAIN constant varchar2(32) := 'services';
function get_portlet_info
(
p_provider_id in integer
,p_language in varchar2
)
return wwpro_api_provider.portlet_record
is
l_portlet wwpro_api_provider.portlet_record;
begin
...
l_portlet.id := services_provider.SERVICES_PORTLET_ID;
l_portlet.provider_id := p_provider_id;
l_portlet_title := wwnls_api.get_string(
p_domain => DOMAIN
,p_sub_domain => SUBDOMAIN
,p_name => 'ptldeftitle'
,p_language => p_language
);
l_portlet_description := wwnls_api.get_string(
p_domain => DOMAIN
,p_sub_domain => SUBDOMAIN
,p_name => 'ptldefdesc'
,p_language => p_language
);
l_portlet_name := wwnls_api.get_string(
p_domain => DOMAIN
,p_sub_domain => SUBDOMAIN
,p_name => 'ptldefname'
,p_language => p_language
);
...
...
end SERVICES_PORTLET;
/
Similarly you can use NLS strings wherever your functionality requires it. When you incorporate other services like Error Handling, you will find this especially useful.
| Revision History: |
|
| Oracle Corporation World Headquarters 500 Oracle Parkway Redwood Shores, CA 94065, USA http://www.oracle.com/ |
Worldwide Inquiries: 1-800-ORACLE1 Fax 650.506.7200 |
Copyright and Corporate Info |