Oracle® Database Globalization Support Guide 10g Release 1 (10.1) Part Number B10749-01 |
|
|
View PDF |
This chapter includes the following sections:
Designing and developing a globalized application can be a daunting task even for the most experienced developers. This is usually caused by lack of knowledge and the complexity of globalization concepts and APIs. Application developers who write applications using the Oracle database need to understand the Globalization Support architecture of the database, including the properties of the different character sets, territories, languages and linguistic sort definitions. They also need to understand the globalization functionality of their middle-tier programming environment, and find out how it can interact and synchronize with the locale model of the database. Finally, to develop a globalized Internet application, they need to design and write code that is capable of simultaneously supporting multiple clients running on different operating systems with different character sets and locale requirements.
Oracle Globalization Development Kit (GDK) simplifies the development process and reduces the cost of developing Internet applications that will be used to support a global environment.
This release of the GDK includes comprehensive programming APIs for both Java and PL/SQL, code samples, and documentation that address many of the design, development, and deployment issues encountered while creating global applications.
The GDK mainly consists of two parts: GDK for Java and GDK for PL/SQL. GDK for Java provides globalization support to Java applications. GDK for PL/SQL provides globalization support to the PL/SQL programming environment. The features offered in GDK for Java and GDK for PL/SQL are not identical.
There are two architectural models for deploying a global Web site or a global Internet application, depending on your globalization and business requirements. Which model to deploy affects how the Internet application is developed and how the application server is configured in the middle-tier. The two models are:
Internet applications that support only one locale in a single binary are classified as monolingual applications. A locale refers to a national language and the region in which the language is spoken. For example, the primary language of the United States and Great Britain is English. However, the two territories have different currencies and different conventions for date formats. Therefore, the United States and Great Britain are considered to be two different locales.
This level of globalization support is suitable for customers who want to support one locale for each instance of the application. Users need to have different entry points to access the applications for different locales. This model is manageable only if the number of supported locales is small.
Internet applications that support multiple locales simultaneously in a single binary are classified as multilingual applications. This level of globalization support is suitable for customers who want to support several locales in an Internet application simultaneously. Users of different locale preferences use the same entry point to access the application.
Developing an application using the monolingual model is very different from developing an application using the multilingual model. The Globalization Development Kit consists of libraries, which can assist in the development of global applications using either architectural model.
The rest of this section includes the following topics:
Deploying a global Internet application with multiple instances of monolingual Internet applications is shown in Figure 8-1.
Text description of the illustration nlspg035.gif
Each application server is configured for the locale that it serves. This deployment model assumes that one instance of an Internet application runs in the same locale as the application in the middle tier.
The Internet applications access a back-end database in the native encoding used for the locale. The following are advantages of deploying monolingual Internet applications:
The following are disadvantages of deploying monolingual Internet applications:
As more and more locales are supported, the disadvantages quickly outweigh the advantages. With the limitation and the maintenance overhead of the monolingual deployment model, this deployment architecture is suitable for applications that support only one or two locales.
Multilingual Internet applications are deployed to the application servers with a single application server configuration that works for all locales. Figure 8-2 shows the architecture of a multilingual Internet application.
Text description of the illustration nlspg034.gif
To support multiple locales in a single application instance, the application may need to do the following:
The following are major advantages of deploying multilingual Internet application:
The disadvantage of deploying multilingual Internet applications is that it requires extra coding during application development to handle dynamic locale detection and Unicode, which is costly when only one or two languages need to be supported.
Deploying multilingual Internet applications is more appropriate than deploying monolingual applications when Web sites support multiple locales.
Building an Internet application that supports different locales requires good development practices.
For multilingual Internet applications, the application itself must be aware of the user's locale and be able to present locale-appropriate content to the user. Clients must be able to communicate with the application server regardless of the client's locale. The application server then communicates with the database server, exchanging data while maintaining the preferences of the different locales and character set settings. One of the main considerations when developing a multilingual internet application is to be able to dynamically detect, cache, and provide the appropriate contents according to the user's preferred locale.
For monolingual Internet applications, the locale of the user is always fixed and usually follows the default locale of the runtime environment. Hence the locale configuration is much simpler.
The following sections describe some of the most common issues that developers encounter when building a global Internet application:
To be locale-aware or locale-sensitive, Internet applications need to be able to determine the preferred locale of the user.
Monolingual applications always serve users with the same locale, and that locale should be equivalent to the default runtime locale of the corresponding programming environment.
Multilingual applications can determine a user locale dynamically in three ways. Each method has advantages and disadvantages, but they can be used together in the applications to complement each other. The user locale can be determined in the following ways:
The schema for the user profile should include preferred locale attribute to indicate the locale of a user. This way of determining a locale user does not work if a user has not been logged on before.
Get the default ISO locale setting from a browser. The default ISO locale of the browser is sent through the Accept-Language HTTP header in every HTTP request. If the Accept-Language header is NULL, then the desired locale should default to English. The drawback of this approach is that the Accept-Language header may not be a reliable source of information for the locale of a user.
Allow users to select a locale from a list box or from a menu, and switch the application locale to the one selected.
The Globalization Development Kit provides an application framework that enables you to use these locale determination methods declaratively.
To be locale-aware or locale-sensitive, Internet applications need to determine the locale of a user. After the locale of a user is determined, applications should:
Locale-sensitive functions, such as date, time, and monetary formatting, are built into various programming environments such as Java and PL/SQL. Applications may use them to format the HTML pages according to the cultural conventions of the locale of a user. A locale is represented differently in different programming environments. For example, the French (Canada) locale is represented in different environments as follows:
fr-CA
where fr
is the language code defined in the ISO 639 standard and CA
is the country code defined in the ISO 3166 standard.fr
, the ISO language code for French, as the language and CA
, the ISO country code for Canada, as the country. The Java locale name is fr_CA
.NLS_LANGUAGE
and NLS_TERRITORY
session parameters where the value of the NLS_LANGUAGE
parameter is equal to CANADIAN FRENCH
and the value of the NLS_TERRITORY
parameter is equal to CANADA
.If you write applications for more than one programming environment, then locales must be synchronized between environments. For example, Java applications that call PL/SQL procedures should map the Java locales to the corresponding NLS_LANGUAGE
and NLS_TERRITORY
values and change the parameter values to match the user's locale before calling the PL/SQL procedures.
The Globalization Development Kit for Java provides a set of Java classes to ensure consistency on locale-sensitive behaviors with Oracle databases.
For the application to support a multilingual environment, it must be able to present the content in the preferred language and in the locale convention of the user. Hard-coded user interface text must first be externalized from the application, together with any image files, so that they can be translated into the different languages supported by the application. The translation files then must be staged in separate directories, and the application must be able to locate the relevant content according to the user locale setting. Special application handling may also be required to support a fallback mechanism, so that if the user-preferred locale is not available, then the next most suitable content is presented. For example, if Canadian French content is not available, then it may be suitable for the application to switch to the French files instead.
The Globalization Development Kit (GDK) for Java provides a J2EE application framework and Java APIs to develop globalized Internet applications using the best globalization practices and features designed by Oracle. It reduces the complexities and simplifies the code that Oracle developers require to develop globalized Java applications.
GDK for Java complements the existing globalization features in J2EE. Although the J2EE platform already provides a strong foundation for building globalized applications, its globalization functionalities and behaviors can be quite different from Oracle's functionalities. GDK for Java provides synchronization of locale-sensitive behaviors between the middle-tier Java application and the database server.
GDK for PL/SQL contains a suite of PL/SQL packages that provide additional globalization functionalities for applications written in PL/SQL.
Figure 8-3 shows the major components of the GDK and how they are related to each other. User applications run on the J2EE container of Oracle Application Server in the middle tier. GDK provides the application framework that the J2EE application uses to simplify coding to support globalization. Both the framework and the application call the GDK Java API to perform locale-sensitive tasks. GDK for PL/SQL offers PL/SQL packages that help to resolve globalization issues specific to the PL/SQL environment.
Text description of the illustration nlspg036.gif
The functionalities offered by GDK for Java can be divided into two categories:
GDK for Java is contained in two files: orai18n.jar
and orai18n-lcsd.jar
. The files are shipped with the Oracle database. If the application using the GDK is not hosted on the same machine as the database, then the GDK files must be copied to the application server and included into the CLASSPATH
to run your application. You do not need to install the Oracle Database into your application server to be able to run the GDK inside your Java application. GDK is a pure Java library that runs on every platform. The Oracle client parameters NLS_LANG
and ORACLE_HOME
are not required.
GDK for Java provides the globalization framework for middle-tier J2EE applications. The framework encapsulates the complexity of globalization programming, such as determining user locale, maintaining locale persistency, and processing locale information. This framework minimizes the effort required to make Internet applications global-ready. The GDK application framework is shown in Figure 8-4.
Text description of the illustration nlspg038.gif
The main Java classes composing the framework are as follows:
ApplicationContext
provides the globalization context of an application. The context information includes the list of supported locales and the rule for determining user-preferred locale. The context information is obtained from the GDK application configuration file for the application.LocaleSource
classes can be plugged into the framework. Each LocaleSource
class implements the LocaleSource
interface to get the locale from the corresponding source. Oracle bundles several LocaleSource
classes in GDK. For example, the DBLocaleSource
class obtains the locale information of the current user from a database schema. You can also write a customized LocaleSource
class by implementing the same LocaleSource
interface and plugging it into the framework.ServletRequestWrapper
and ServletResponseWrapper
are the main classes of the GDK Servlet filter that transforms HTTP requests and HTTP responses. ServletRequestWrapper
instantiates a Localizer
object for each HTTP request based on the information gathered from the ApplicationContext
and LocaleSource
objects and ensures that forms parameters are handled properly. ServletResponseWrapper
controls how HTTP response should be constructed.Localizer
is the all-in-one object that exposes the important functions that are sensitive to the current user locale and application context. It provides a centralized set of methods for you to call and make your applications behave appropriately to the current user locale and application context.The GDK application framework simplifies the coding required for your applications to support different locales. When you write a J2EE application according to the application framework, the application code is independent of what locales the application supports, and you control the globalization support in the application by defining it in the GDK application configuration file. There is no code change required when you add or remove a locale from the list of supported application locales.
The following list gives you some idea of the extent to which you can define the globalization support in the GDK application configuration file:
LocaleSource
object into the framework and use it to detect a user locale.This section includes the following topics:
The behavior of the GDK application framework for J2EE is controlled by the GDK application configuration file, gdkapp.xml
. The application configuration file allows developers to specify the behaviors of globalized applications in one centralized place. One application configuration file is required for each J2EE application using the GDK. The gdkapp.xml
file should be placed in the ./WEB-INF
directory of the J2EE environment of the application. The file dictates the behavior and the properties of the GDK framework and the application that is using it. It contains locale mapping tables, character sets of content files, and globalization parameters for the configuration of the application. The application administrator can modify the application configuration file to change the globalization behavior in the application, without needing to change the programs and to recompile them.
For a J2EE application to use the GDK application framework defined by the corresponding GDK application configuration file, the GDK Servlet filter and the GDK context listener must be defined in the web.xml
file of the application. The web.xml
file should be modified to include the following at the beginning of the file:
<web-app> <!-- Add GDK filter that is called after the authentication --> <filter> <filter-name>gdkfilter</filter-name> <filter-class>oracle.i18n.servlet.filter.ServletFilter</filter-class> </filter> <filter-mapping> <filter-name>gdkfilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <!-- Include the GDK context listener --> <listener> <listener-class>oracle.i18n.servlet.listener.ContextListener</listener-class> </listener> </web-app>
Examples of the gdkapp.xml
and web.xml
files can be found in the $ORACLE_HOME/nls/gdk/demo
directory.
The GDK application framework supports Servlet container version 2.3 and later. It uses the Servlet filter facility for transparent globalization operations such as determining the user locale and specifying the character set for content files. The ApplicationContextListener
instantiates GDK application parameters described in the GDK application configuration file. The ServletFilter
overrides the request and response objects with a GDK request (ServletRequestWrapper
) and response (ServletResponseWrapper
) objects, respectively.
If other application filters used in the application also override the same methods, then the filter in the GDK framework may return incorrect results. For example, if getLocale
returns en_US
, but the result is overridden by other filters, then the result of the GDK locale detection mechanism is affected. All of the methods that are being overridden in the filter of the GDK framework are documented in Oracle Globalization Development Kit Java API Reference. Be aware of potential conflicts when using other filters together with the GDK framework.
Determining the user's preferred locale is the first step in making an application global-ready. The locale detection offered by the J2EE application framework is primitive. It lacks the method that transparently retrieves the most appropriate user locale among locale sources. It provides locale detection by the HTTP language preference only, and it cannot support a multilevel locale fallback mechanism. The GDK application framework provides support for predefined locale sources to complement J2EE. In a web application, several locale sources are available. Table 8-1 summarizes locale sources that are provided by the GDK.
See Also:
"The GDK Application Configuration File" for information about the GDK multilevel locale fallback mechanism |
The GDK application framework provides seamless support for predefined locale sources, such as user input locale, HTTP language preference, user profile locale preference in the database, and the application default locale. You can incorporate the locale sources to the framework by defining them under the <locale-determine-rule>
tag in the GDK application configuration file as follows:
<locale-determine-rule> <locale-source>oracle.i18n.servlet.localesource.UserInput</locale-source> <locale-source>oracle.i18n.servlet.localesource.HTTPAcceptLanguage</locale-source> </locale-determine-rule>
Custom locale sources, such as locale preference from an LDAP server, can be easily implemented and integrated into the GDK framework. You need to implement the LocaleSource
interface and specify the corresponding implementation class under the <locale-determine-rule>
tag in the same way as the predefined locale sources were specified.
The LocaleSource
implementation not only retrieves the locale information from the corresponding source to the framework but also updates the locale information to the corresponding source when the framework tells it to do so. Locale sources can be read-only or read/write, and they can be cacheable or noncacheable. The GDK framework initiates updates only to read/write locale sources and caches the locale information from cacheable locale sources. Examples of custom locale sources can be found in the $ORACLE_HOME/nls/gdk/demo
directory.
See Also:
Oracle Globalization Development Kit Java API Reference for more information about implementing a |
The GDK offers automatic locale detection to determine the current locale of the user. For example, the following code retrieves the current user locale in Java. It uses a Locale
object explicitly.
Locale loc = request.getLocale();
The getLocale()
method returns the Locale
that represents the current locale. This is similar to invoking the HttpServletRequest.getLocale()
method in JSP or Java Servlet code. However, the logic in determining the user locale is different, because multiple locale sources are being considered in the GDK framework.
Alternatively, you can get a Localizer
object that encapsulates the Locale
object determined by the GDK framework. For the benefits of using the Localizer
object, see "Implementing Locale Awareness Using the GDK Localizer".
Localizer localizer = ServletHelper.getLocalizerInstance(request); Locale loc = localizer.getLocale();
The locale detection logic of the GDK framework depends on the locale sources defined in the GDK application configuration file. The names of the locale sources are registered in the application configuration file. The following example shows the locale determination rule section of the application configuration file. It indicates that the user-preferred locale can be determined from either the LDAP server or from the HTTP Accept-Language
header. The LDAPUserSchema
locale source class should be provided by the application. Note that all of the locale source classes have to be extended from the LocaleSource
abstract class.
<locale-determine-rule> <locale-source>LDAPUserSchema</locale-source> <locale-source>oracle.i18n.localesource.HTTPAcceptLanguage</locale-source> </locale-determine-rule>
For example, when the user is authenticated in the application and the user locale preference is stored in an LDAP server, then the LDAPUserSchema
class connects to the LDAP server to retrieve the user locale preference. When the user is anonymous, then the HttpAcceptLanguage
class returns the language preference of the web browser.
The cache is maintained for the duration of a HTTP session. If the locale source is obtained from the HTTP language preference, then the locale information is passed to the application in the HTTP Accept-Language
header and not cached. This enables flexibility so that the locale preference can change between requests. The cache is available in the HTTP session.
The GDK framework exposes a method for the application to overwrite the locale preference information persistently stored in locale sources such as the LDAP server or the user profile table in the database. This method also resets the current locale information stored inside the cache for the current HTTP session. The following is an example of overwriting the preferred locale using the store
command.
<input type="hidden" name="<%=appctx.getParameterName(LocaleSource.Parameter.COMMAND)%>" value="store">
To discard the current locale information stored inside the cache, the clean
command can be specified as the input parameter. The following table shows the list of commands supported by the GDK:
Note that the GDK parameter names can be customized in the application configuration file to avoid name conflicts with other parameters used in the application.
The Localizer
object obtained from the GDK application framework is an all-in-one globalization object that provides access to functions that are commonly used in building locale awareness in your applications. In addition, it provides functions to get information about the application context, such as the list of supported locales. The Localizer
object simplifies and centralizes the code required to build consistent locale awareness behavior in your applications.
The oracle.i18n.servlet
package contains the Localizer
class. You can get the Localizer instance as follows:
Localizer lc = ServletHelper.getLocalizerInstance(request);
The Localizer
object encapsulates the most commonly used locale-sensitive information determined by the GDK framework and exposes it as locale-sensitive methods. This object includes the following functionalities pertaining to the user locale:
For example, when you want to display a date in your application, you may want to call the Localizer.formatDate()
or Localizer.formateDateTime()
methods. When you want to determine the writing direction of the current locale, you can call the Localizer.getWritingDirection()
and Localizer.getAlignment()
to determine the value used in the <DIR>
tag and <ALIGN>
tag respectively.
The Localizer
object also exposes methods to enumerate the list of supported locales and their corresponding languages and countries in your applications.
The Localizer
object actually makes use of the classes in the GDK Java API to accomplish its tasks. These classes includes, but are not limited to, the following: OraDateFormat
, OraNumberFormat
, OraCollator
, OraLocaleInfo
, oracle.i18n.util.LocaleMapper
, oracle.i18n.net.URLEncoder
, and oracle.i18n.net.URLDecoder
.
The Localizer
object simplifies the code you need to write for locale awareness. It maintains caches of the corresponding objects created from the GDK Java API so that the calling application does not need to maintain these objects for subsequent calls to the same objects. If you require more than the functionality the Localizer
object can provide, then you can always call the corresponding methods in the GDK Java API directly.
See Also:
Oracle Globalization Development Kit Java API Reference for detailed information about the |
The number of locales and the names of the locales that an application needs to support are based on the business requirements of the application. The names of the locales that are supported by the application are registered in the application configuration file. The following example shows the application locales section of the application configuration file. It indicates that the application supports German (de
), Japanese (ja
), and English for the US (en-US
), with English defined as the default fallback application locale.
<application-locales> <locale>de</locale> <locale>ja</locale> <locale default="yes">en-US</locale> </application-locales>
When the GDK framework detects the user locale, it verifies whether the locale that is returned is one of the supported locales in the application configuration file. The verification algorithm is as follows:
de_DE_EURO
has a EURO
variant. Remove the variant so that the resulting locale is de_DE
.de_DE
has a country code of DE
. Remove the country code so that the resulting locale is de
.By performing steps 3 and 4, the application can support users with the same language requirements but with different locale settings than those defined in the application configuration file. For example, the GDK can support de-AT
(the Austrian variant of German), de-CH
(the Swiss variant of German), and de-LU
(the Luxembourgian variant of German) locales.
The locale fallback detection in the GDK framework is similar to that of the Java Resource Bundle, except that it is not affected by the default locale of the Java VM. This exception occurs because the Application Default Locale can be used during the GDK locale fallback operations.
If the application-locales section is omitted from the application configuration file, then the GDK assumes that the common locales, which can be returned from the OraLocaleInfo.getCommonLocales
method, are supported by the application.
The character set (or character encoding) of an HTML page is a very important piece of information to a browser and an Internet application. The browser needs to interpret this information so that it can use correct fonts and character set mapping tables for displaying pages. The Internet applications need to know so they can safely process input data from a HTML form based on the specified encoding.
The page encoding can be translated as the character set used for the locale to which an Internet application is serving. In order to correctly specify the page encoding for HTML pages without using the GDK framework, Internet applications must:
Applications using the GDK framework can ignore these steps. No application code change is required. The character set information is specified in the GDK application configuration file. At runtime, the GDK automatically sets the character sets for the request and response objects. The GDK framework does not support the scenario where the incoming character set is different from that of the outgoing character set.
The GDK application framework supports the following scenarios for setting the character sets of the HTML pages:
The character set information is specified in the GDK application configuration file. The following is an example of setting UTF-8 as the character set for all the application pages.
<page-charset>UTF-8</page-charset>
The page character set information is used by the ServletRequestWrapper
class, which sets the proper character set for the request object. It is also used by the ContentType
HTTP header specified in the ServletResponseWrapper
class for output when instantiated. If page-charset
is set to AUTO-CHARSET
, then the character set is assumed to be the default character set for the current user locale. Set page-charset
to AUTO-CHARSET
as follows:
<page-charset>AUTO-CHARSET</page-charset>
The default mappings are derived from the LocaleMapper
class, which provides the default IANA character set for the locale name in the GDK Java API.
Table 8-2 lists the mappings between the common ISO locales and their IANA character sets.
The locale to character set mapping in the GDK is also be customized. To override the default mapping defined in the GDK Java API, a locale-to-character-set mapping table can be specified in the application configuration file.
<locale-charset-maps> <locale-charset> <locale>ja</locale><charset>EUC-JP</charset> </locale-charset> </locale-charset-maps>
The previous example shows that for locale Japanese (ja
), the GDK changes the default character set from SHIFT_JIS to EUC-JP.
This section includes the following topics:
Resource bundles enable access to localized contents at runtime in J2SE. Translatable strings within Java servlets and Java Server Pages (JSPs) are externalized into Java resource bundles so that these resource bundles can be translated independently into different languages. The translated resource bundles carry the same base class names as the English bundles, using the Java locale name as the suffix.
To retrieve translated data from the resource bundle, the getBundle()
method must be invoked for every request.
<% Locale user_locale=request.getLocale(); ResourceBundle rb=ResourceBundle.getBundle("resource",user_locale); %> <%= rb.getString("Welcome") %>
The GDK framework simplifies the retrieval of text strings from the resource bundles. Localizer.getMessage()
is a wrapper to the resource bundle.
<% Localizer.getMessage ("Welcome") %>
Instead of specifying the base class name as getBundle()
in the application, you can specify the resource bundle in the application configuration file, so that the GDK automatically instantiates a ResourceBundle
object when a translated text string is requested.
<message-bundles> <resource-bundle name="default">resource</resource-bundle> </message-bundles>
Multiple resource bundles can be specified in the configuration file. To access a nondefault bundle, specify the name
parameter in the getMessage
method.
For a application, which supports only one locale, the URL that has a suffix of /index.html
typically takes the user to the starting page of the application.
In a globalized application, contents in different languages are usually stored separately, and it is common for them to be staged in different directories or with different file names based on the language or the country name. This information is then used to construct the URLs for localized content retrieval in the application.
The following examples illustrate how to retrieve the French and Japanese versions of the index page. Their suffixes are as follows:
/fr/index.html /ja/index.html
By using the rewriteURL()
method, the GDK framework handles the logic to locate the translated files from the corresponding language directories. The ServletHelper.rewriteURL()
method rewrites a URL based on the rules specified in the application configuration file. This method is used to determine the correct location where the localized content is staged.
The following is an example of the JSP code:
<img src="<%="ServletHelper.rewriteURL("image/welcome.jpg", request)%>"> <a href="<%="ServletHelper.rewriteURL("html/welcome.html", request)%>">
The URL rewrite definitions are defined in the GDK application configuration file:
<url-rewrite-rule fallback="yes"> <pattern>(.*)/(a-zA-Z0-9_\]+.)$</pattern> <result>$1/$A/$2</result> </url-rewrite-rule>
The pattern section defined in the rewrite rule follow the regular expression conventions. The result section supports the following special variables for replacing:
$L
is used to represent the ISO 639 language code part of the current user locale$C
represents the ISO 3166 country code$A
represents the entire locale string, where the ISO 639 language code and ISO 3166 country code are connected with an underscore character (_
)For example, if the current user locale is ja
, then the URL for the welcome.jpg
image file is rewritten as image/ja/welcome.jpg
, and welcome.html
is changed to html/ja/welcome.html
.
Both ServletHelper.rewriteURL()
and Localizer.getMessage()
methods perform consistent locale fallback operations in the case where the translation files for the user locale are not available. For example, if the online help files are not available for the es_MX
locale (Spanish for Mexico), but the es
(Spanish for Spain) files are available, then the methods will select the Spanish translated files as the substitute.
Java's globalization functionalities and behaviors are not the same as those offered in the database. For example, J2SE supports a set of locales and character sets that are different from Oracle's locales and character sets. This inconsistency can be confusing for users when their application contains data that is formatted based on 2 different conventions. For example, dates that are retrieved from the database are formatted using Oracle conventions, (such as number and date formatting and linguistic sort ordering), but the static application data are typically formatted using Java locale conventions. Java's globalization functionalities can also be different depending on the version of the JDK that the application runs on.
Before Oracle Database 10g, when an application was required to incorporate Oracle globalization features, it had to make connections to the database server and issue SQL statements. Such operations make the application complicated and generate more network connections to the database server.
The GDK Java API extends Oracle's database globalization features to the middle tier. By enabling applications to perform globalization logic such as Oracle date and number formatting and linguistic sorting in the middle tier, the GDK Java API allows developers to eliminate expensive programming logic in the database, hence improving the overall application performance by reducing the database load in the database server and the unnecessary network traffic between the application tier and the database server.
The GDK Java API also offers advance globalization functionalities, such as language and character set detection, and the enumeration of common locale data for a territory or a language (for example, all time zones supported in Canada). These are globalization features that are not available in most programming platforms. Without the GDK Java API, developers must write business logic to handle them inside an application.
The following are the key functionalities of the GDK Java API:
Oracle locale definitions, which include languages, territories, linguistic sorts, and character sets, are exposed in the GDK Java API. The naming convention that Oracle uses may also be different from other vendors. Although many of these names and definitions follow industry standards, some are Oracle-specific, tailored to meet special customer requirements.
OraLocaleInfo
is an Oracle locale class that includes language, territory, and collator objects. It provides a method for applications to retrieve a collection of locale-related objects for a given locale, for example, a full list of the Oracle linguistic sorts available in the GDK, the local time zones defined for a given territory, or the common languages used in a particular territory.
The following are examples of using the OraLocaleInfo
class:
// All Territories supported by GDK String[] avterr = OraLocaleInfo.getAvailableTerritories(); // Local TimeZones for a given Territory OraLocaleInfo oloc = OraLocaleInfo.getInstance("English", "Canada"); TimeZone[] loctz = oloc.getLocalTimeZones();
The GDK Java API provides the LocaleMapper
class. It maps equivalent locales and character sets between Java, IANA, ISO, and Oracle. A Java application may receive locale information from the client that is specified in Oracle's locale name or an IANA character set name. The Java application must be able to map to an equivalent Java locale or Java encoding before it can process the information correctly.
The following is an example of using the LocaleMapper
class.
// Mapping from Java locale to Oracle language and Oracle territory Locale locale = new Locale("it", "IT"); String oraLang = LocaleMapper.getOraLanguage(locale); String oraTerr = LocaleMapper.getOraTerritory(locale); // From Oracle language and Oracle territory to Java Locale locale = LocaleMapper.getJavaLocale("AMERICAN","AMERICA"); locale = LocaleMapper.getJavaLocale("TRADITONAL CHINESE", ""); // From IANA & Java to Oracle Character set String ocs1 = LocaleMapper.getOraCharacterSet( LocaleMapper.IANA, "ISO-8859-1"); String ocs2 = LocaleMapper.getOraCharacterSet( LocaleMapper.JAVA, "ISO8859_1");
The LocaleMapper
class can also return the most commonly used e-mail character set for a specific locale on both Windows and UNIX platforms. This is useful when developing Java applications that need to process e-mail messages.
The GDK Java API contains a set of character set conversion classes APIs that enable users to perform Oracle character set conversions. Although Java JDK is already equipped with classes that can perform conversions for many of the standard character sets, they do not support Oracle-specific character sets and Oracle's user-defined character sets.
In JDK 1.4, J2SE introduced an interface for developers to extend Java's character sets. The GDK Java API provides implicit support for Oracle's character sets by using this plug-in feature. You can access the J2SE API to obtain Oracle-specific behaviors.
Figure 8-5 shows that the GDK character set conversion tables are plugged into J2SE in the same way as the Java character set tables. With this pluggable framework of J2SE, the Oracle character set conversions can be used in the same way as other Java character set conversions.
Text description of the illustration nlspg037.gif
Because the java.nio.charset
Java package is not available in JDK versions before 1.4, you must install JDK 1.4 or later to use Oracle's character set plug-in feature.
The GDK character conversion classes support all Oracle character sets including user-defined characters sets. It can be used by Java applications to properly convert to and from Java's internal character set, UTF-16.
Oracle's character set names are proprietary. To avoid potential conflicts with Java's own character sets, all Oracle character set names have an X-ORACLE-
prefix for all implicit usage through Java's API.
The following is an example of Oracle character set conversion:
// Converts the Chinese character "three" from UCS2 to JA16SJIS String str = "\u4e09"; byte[] barr = str.getBytes("x-oracle-JA16SJIS");
Like other Java character sets, the character set facility in java.nio.charset.Charset
is also application to all of the Oracle character sets. For example, if you wish to check whether the specified character set is a superset of another character set, then you can use the Charset.contains
method as follows:
Charset cs1 = Charset.forName("x-oracle-US7ASCII"); Charset cs2 = Charset.forName("x-oracle-WE8WINDOWS1252"); // true if WE8WINDOWS1252 is the superset of US7ASCII, otherwise false. boolean osc = cs2.contains(cs1);
For a Java application that is using the JDBC driver to communicate with the database, the JDBC driver provides the necessary character set conversion between the application and the database. Calling the GDK character set conversion methods explicitly within the application is not required. A Java application that interprets and generates text files based on Oracle's character set encoding format is an example of using Oracle character set conversion classes.
The GDK Java API provides formatting classes that support date, number, and monetary formats using Oracle conventions for Java applications in the oracle.i18n.text
package.
New locale formats introduced in Oracle Database 10g, such as the short and long date, number, and monetary formats, are also exposed in these format classes.
The following are examples of Oracle date, Oracle number, and Oracle monetary formatting:
// Obtain the current date and time in the default Oracle LONG format for // the locale de_DE (German_Germany) Locale locale = new Locale("de", "DE"); OraDateFormat odf = OraDateFormat.getDateTimeInstance(OraDateFormat.LONG, locale); // Obtain the numeric value 1234567.89 using the default number format // for the Locale en_IN (English_India) locale = new Locale("en", "IN"); OraNumberFormat onf = OraNumberFormat.getNumberInstance(locale); String nm = onf.format(new Double(1234567.89)); // Obtain the monetary value 1234567.89 using the default currency // format for the Locale en_US (American_America) locale = new Locale("en", "US"); onf = OraNumberFormat.getCurrencyInstance(locale); nm = onf.format(new Double(1234567.89));
Oracle provides support for binary, monolingual, and multilingual linguistic sorts in the database. In Oracle Database 10g, these sorts have been expanded to provide case-insensitive and accent-insensitive sorting and searching capabilities inside the database. By using the OraCollator
class, the GDK Java API enables Java applications to sort and search for information based on the latest Oracle binary and linguistic sorting features, including case-insensitive and accent-insensitive options.
Normalization can be an important part of sorting. The composition and decomposition of characters are based on the Unicode Standard, so sorting also depends on the Unicode standard. Because each version of the JDK may support a different version of the Unicode Standard, the GDK provides an OraNormalizer
class based on the Unicode 3.2 standard. It contains methods to perform composition.
The sorting order of a binary sort is based on the Oracle character set that is being used. Except for the UTFE character set, the binary sorts of all Oracle character sets are supported in the GDK Java API. The only linguistic sort that is not supported in the GDK Java API is JAPANESE, but a similar and more accurate sorting result can be achieved by using JAPANESE_M.
The following are examples of string comparisons and string sorting:
// compares strings using XGERMAN private static String s1 = "abcSS"; private static String s2 = "abc\u00DF"; String cname = "XGERMAN"; OraCollator ocol = OraCollator.getInstance(cname); int c = ocol.compare(s1, s2); // sorts strings using GENERIC_M private static String[] source = new String[] { "Hochgeschwindigkeitsdrucker", "Bildschirmfu\u00DF", "Skjermhengsel", "DIMM de Mem\u00F3ria", "M\u00F3dulo SDRAM com ECC", }; cname = "GENERIC_M"; ocol = OraCollator.getInstance(cname); List result = getCollationKeys(source, ocol); private static List getCollationKeys(String[] source, OraCollator ocol) { List karr = new ArrayList(source.length); for (int i = 0; i < source.length; ++i) { karr.add(ocol.getCollationKey(source[i])); } Collections.sort(karr); // sorting operation return karr; }
The Oracle Language and Character Set Detection Java classes in the GDK Java API provide a high performance, statistically based engine for determining the character set and language for unspecified text. It can automatically identify language and character set pairs, from throughout the world. With each text, the language and character set detection engine sets up a series of probabilities, each probability corresponding to a language and character set pair. The most probable pair statistically identifies the dominant language and character set.
The purity of the text submitted affects the accuracy of the language and character set detection. Only plain text strings are accepted, so any tagging needs to be stripped before hand. The ideal case is literary text with almost no foreign words or grammatical errors. Text strings that contain a mix of languages or character sets, or nonnatural language text like addresses, phone numbers, and programming language code may yield poor results.
The LCSDetector
class can detect the language and character set of a byte array, a character array, a string, and an InputStream
class. It can take the entire input for sampling or only portions of the input for sampling, when the length or both the offset and the length are supplied. For each input, up to three potential language and character set pairs can be returned by the LCSDetector
class. They are always ranked in sequence, with the pair with the highest probability returned first.
See Also:
"Language and Character Set Detection Support" for a list of supported language and character set pairs |
The following are examples of using the LCSDetector class to enable language and character set detection:
// This example detects the character set of a plain text file "foo.txt" and // then appends the detected ISO character set name to the name of the text file LCSDetector lcsd = new LCSDetector(); File oldfile = new File("foo.txt"); FileInputStream in = new FileInputStream(oldfile); lcsd.detect(in); String charset = lcsd.getResult().getIANACharacterSet(); File newfile = new File("foo."+charset+".txt"); oldfile.renameTo(newfile); // This example shows how to use the LCSDector class to detect the language and // character set of a byte array int offset = 0; LCSDetector led = new LCSDetector(); /* loop through the entire byte array */ while ( true ) { bytes_read = led.detect(byte_input, offset, 1024); if ( bytes_read == -1 ) break; offset += bytes_read; } LCSDResultSet res = led.getResult(); /* print the detection results with close ratios */ System.out.println("the best guess " ); System.out.println("Langauge " + res.getOraLanguage() ); System.out.println("CharacterSet " + res.getOraCharacterSet() ); int high_hit = res.getHiHitPairs(); if ( high_hit >= 2 ) { System.out.println("the second best guess " ); System.out.println("Langauge " + res.getOraLanguage(2) ); System.out.println("CharacterSet " +res.getOraCharacterSet(2) ); } if ( high_hit >= 3 ) { System.out.println("the third best guess "); System.out.println("Langauge " + res.getOraLanguage(3) ); System.out.println("CharacterSet " +res.getOraCharacterSet(3) ); }
All of the Oracle language names, territory names, character set names, linguistic sort names, and time zone names have been translated into 27 languages including English. They are readily available for inclusion into the user applications, and they provide consistency for the display names across user applications in different languages. OraDisplayLocaleInfo
is a utility class that provides the translations of locale and attributes. The translated names are useful for presentation in user interface text and for drop-down selection boxes. For example, a native French speaker prefers to select from a list of time zones displayed in French than in English.
The following is an example of using OraDisplayLocaleInfo
to return a list of time zones supported in Canada, using the French translation names:
OraLocaleInfo oloc = OraLocaleInfo.getInstance("CANADIAN FRENCH", "CANADA"); OraDisplayLocaleInfo odloc = OraDisplayLocaleInfo.getInstance(oloc); TimeZone[] loctzs = oloc.getLocaleTimeZones(); String [] disptz = new string [loctzs.length]; for (int i=0; i<loctzs.length; ++i) { disptz [i]= odloc.getDisplayTimeZone(loctzs[i]); ... }
You can use the GDK LocaleMapper
class to retrieve the most commonly used e-mail character set. Call LocaleMapper.getIANACharSetFromLocale
, passing in the locale object. The return value is an array of character set names. The first character set returned is the most commonly used e-mail character set.
The following is an example of sending an e-mail message containing Simplified Chinese data in GBK:
import oracle.i18n.util.LocaleMapper; import java.util.Date; import java.util.Locale; import java.util.Properties; import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeUtility; /** * Email send operation sample * * javac -classpath orai18n.jar:j2ee.jar EmailSampleText.java * java -classpath .:orai18n.jar:j2ee.jar EmailSampleText */ public class EmailSampleText { public static void main(String[] args) { send("localhost", // smtp host name "your.address@your-company.com", // from email address "You", // from display email "somebody@some-company.com", // to email address "Subject test zh CN", // subject "Content 4E02 from Text email", // body new Locale("zh", "CN") // user locale ); } public static void send(String smtp, String fromEmail, String fromDispName, String toEmail, String subject, String content, Locale locale ) { // get the list of common email character sets final String[] charset = LocaleMapper.getIANACharSetFromLocale(LocaleMapper. EMAIL_WINDOWS, locale ); // pick the first one for the email encoding final String contentType = "text/plain; charset=" + charset[0]; try { Properties props = System.getProperties(); props.put("mail.smtp.host", smtp); // here, set username / password if necessary Session session = Session.getDefaultInstance(props, null); MimeMessage mimeMessage = new MimeMessage(session); mimeMessage.setFrom(new InternetAddress(fromEmail, fromDispName, charset[0] ) ); mimeMessage.setRecipients(Message.RecipientType.TO, toEmail); mimeMessage.setSubject(MimeUtility.encodeText(subject, charset[0], "Q")); // body mimeMessage.setContent(content, contentType); mimeMessage.setHeader("Content-Type", contentType); mimeMessage.setHeader("Content-Transfer-Encoding", "8bit"); mimeMessage.setSentDate(new Date()); Transport.send(mimeMessage); } catch (Exception e) { e.printStackTrace(); } } }
The GDK application configuration file dictates the behavior and the properties of the GDK application framework and the application that is using it. It contains locale mapping tables and parameters for the configuration of the application. One configuration file is required for each application.
The gdkapp.xml
application configuration file is a XML document. This file resides in the ./WEB-INF
directory of the J2EE environment of the application.
The following sections describe the contents and the properties of the application configuration file in detail:
This section enables applications to override the mapping from default language to character set provided by the GDK. This mapping is used when the page-charset
is set to AUTO-CHARSET
.
For example, for the en
locale, the default GDK character set is windows-1252
. However, if the application requires ISO-8859-1
, this can be specified as follows:
<locale-charset-maps> <locale-charset> <locale>en</locale> <charset>ISO_8859-1</charset> </locale-charset> </locale-charset-maps>
The locale name is comprised of the language code and the country code, and they should follow the ISO naming convention as defined in ISO 639 and ISO 3166, respectively. The character set name follows the IANA convention.
Optionally, the user-agent parameter can be specified in the mapping table to distinguish different clients.
<locale-charset> <locale>en,de</locale> <user-agent>^Mozilla/ 4.0</user-agent> <charset>ISO-8859-1</charset> </locale-charset>
The previous example shows that if the user-agent
value in the HTTP header starts with Mozilla/4.0
(which indicates older version of web clients) for English (en
) and German (de
) locales, then the GDK sets the character set to ISO-8859-1.
Multiple locales can be specified in a comma-delimited list.
This tag section defines the character set of the application pages. If this is explicitly set to a given character set, then all pages use this character set. The character set name must follow the IANA character set convention.
<page-charset>UTF-8</page-charset>
However, if the page-charset
is set to AUTO-CHARSET
, then the character set is based on the default character set of the current user locale. The default character set is derived from the locale to character set mapping table specified in the application configuration file.
If the character set mapping table in the application configuration file is not available, then the character set is based on the default locale name to IANA character set mapping table in the GDK. Default mappings are derived from OraLocaleInfo
class.
This tag section defines a list of the locales supported by the application.
<application-locales> <locale default="yes">en-US</locale> <locale>de</locale> <locale>zh-CN</locale> </application-locales>
If the language component is specified with the *
country code, then all locale names with this language code qualify. For example, if de-*
(the language code for German) is defined as one of the application locales, then this supports de-AT
(German
- Austria), de
(German-Germany), de-LU
(German-Luxembourg), de-CH
(German-Switzerland), and even irregular locale combination such as de-CN
(German-China). However, the application can be restricted to support a predefined set of locales.
It is recommended to set one of the application locales as the default application locale (by specifying default="yes"
) so that it can be used as a fall back locale for customers who are connecting to the application with an unsupported locale.
This section defines the order in which the preferred user locale is determined. The locale sources should be specified based on the scenario in the application. This section includes the following scenarios:
<locale-source>oracle.i18n.servlet.localesource.HTTPAcceptLanguage</locale-source>
<locale-source>oracle.i18n.servlet.localesource.UserInput</locale-source> <locale-source>oracle.i18n.servlet.localesource.HTTPAcceptLanguage</locale-source>
<db-locale-source data-source-name="jdbc/OracleCoreDS" locale-source-table="customer" user-column="customer_email" user-key="userid" language-column="nls_language" territory-column="nls_territory" timezone-column="timezone" >oracle.i18n.servlet.localesource.DBLocaleSource</db-locale-source> <locale-source>oracle.i18n.servlet.localesource.HttpAcceptLanguage</locale-source>
Note that Scenario 3 includes the predefined database locale source, DBLocaleSource
. It enables the user profile information to be specified in the configuration file without writing a custom database locale source. In the example, the user profile table is called "customer"
. The columns are "customer_email"
, "nls_language"
, "nls_territory"
, and "timezone"
. They store the unique e-mail address, the Oracle name of the preferred language, the Oracle name of the preferred territory, and the time zone ID of a customer. The user-key
is a mandatory attribute that specifies the attribute name used to pass the user ID from the application to the GDK framework.
<locale-source>demo.DatabaseLocaleSource</locale-source> <locale-source>oracle.i18n.servlet.localesource.UserInput</locale-source> <locale-source>oracle.i18n.servlet.localesource.HttpAcceptLanguage</locale-source>
Note that Scenario 4 uses the custom database locale source. If the user profile schema is complex, such as user profile information separated into multiple tables, then the custom locale source should be provided by the application. Examples of custom locale sources can be found in the $ORACLE_HOME/nls/gdk/demo
directory.
The tag defines the name of the locale parameters that are used in the user input so that the current user locale can be passed between requests.
Table 8-3 shows the parameters used in the GDK framework.
The parameter names are used in either the parameter in the HTML form or in the URL.
This tag defines the base class names of the resource bundles used in the application. The mapping is used in the Localizer.getMessage
method for locating translated text in the resource bundles.
<message-bundles> <resource-bundle>Messages</resource-bundle> <resource-bundle name="newresource">NewMessages</resource-bundle> </message-bundles>
If the name attribute is not specified or if it is specified as name="default"
to the <resource-bundle>
tag, then the corresponding resource bundle is used as the default message bundle. To support more than one resource bundle in an application, resource bundle names must be assigned to the nondefault resource bundles. The nondefault bundle names must be passed as a parameter of the getMessage
method.
For example:
Localizer loc = ServletHelper.getLocalizerInstance(request); String translatedMessage = loc.getMessage("Hello"); String translatedMessage2 = loc.getMessage("World", "newresource");
This tag is used to control the behavior of the URL rewrite operations. The rewriting rule is a regular expression.
<url-rewrite-rule fallback="no"> <pattern>(.*)/([^/]+)$</pattern> <result>$1/$L/$2</result> </url-rewrite-rule>
If the localized content for the requested locale is not available, then it is possible for the GDK framework to trigger the locale fallback mechanism by mapping it to the closest translation locale. By default the fallback option is turned off. This can be turned on by specifying fallback="yes"
.
For example, suppose an application supports only the following translations: en
, de
, and ja
, and en
is the default locale of the application. If the current application locale is de-US
, then it falls back to de
. If the user selects zh-TW
as its application locale, then it falls back to en
.
A fallback mechanism is often necessary if the number of supported application locales is greater than the number of the translation locales. This usually happens if multiple locales share one translation. One example is Spanish. The application may need to support multiple Spanish-speaking countries and not just Spain, with one set of translation files.
Multiple URL rewrite rules can be specified by assigning the name attribute to nondefault URL rewrite rules. To use the nondefault URL rewrite rules, the name must be passed as a parameter of the rewrite URL method. For example:
<img src="<%=ServletHelper.rewriteURL("images/welcome.gif", request) %>"> <img src="<%=ServletHelper.rewriteURL("US.gif", "flag", request) %>">
The first rule changes the "images/welcome.gif"
URL to the localized welcome image file. The second rule named "flag"
changes the "US.gif"
URL to the user's country flag image file. The rule definition should be as follows:
<url-rewrite-rule fallback="yes"> <pattern>(.*)/([^/]+)$</pattern> <result>$1/$L/$2</result> </url-rewrite-rule> <url-rewrite-rule name="flag"> <pattern>US.gif/pattern> <result>$C.gif</result> </url-rewrite-rule>
This section contains an example of an application configuration file with the following application properties:
el
), English (en
), German (de
), French (fr
), Japanese (ja
) and Simplified Chinese for China (zh-CN
).ja
locale is always UTF-8.en
and de
locales when using an Internet Explorer client is windows-1252
.en
, de
, and fr
locales on other web browser clients is iso-8859-1
.Accept-Language
./shop/welcome.jpg
is stored in /ja/shop/welcome.jpg
.
<?xml version="1.0" encoding="utf-8"?> <gdkapp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="gdkapp.xsd"> <!-- Language to Character set mapping --> <locale-charset-maps> <locale-charset> <locale>ja</locale> <charset>UTF-8</charset> </locale-charset> <locale-charset> <locale>en,de</locale> <user-agent>^Mozilla\/[0-9\. ]+\(compatible; MSIE [^;]+; \)</user-agent> <charset>WINDOWS-1252</charset> </locale-charset> <locale-charset> <locale>en,de,fr</locale> <charset>ISO-8859-1</charset> </locale-charset> </locale-charset-maps> <!-- Application Configurations --> <page-charset>AUTO-CHARSET</page-charset> <application-locales> <locale>ar</locale> <locale>de</locale> <locale>fr</locale> <locale>ja</locale> <locale>el</locale> <locale default="yes">en</locale> <locale>zh-CN</locale> </application-locales> <locale-determine-rule> <locale-source>oracle.i18n.servlet.localesource.UserInput</locale-source> <locale-source>oracle.i18n.servlet.localesource.HttpAcceptLanguage</locale-source> </locale-determine-rule> <!-- URL rewriting rule --> <url-rewrite-rule fallback="no"> <pattern>(.*)/([^/]+)$</pattern> <result>/$L/$1/$2</result> </url-rewrite-rule> </gdkapp>
Oracle Globalization Services for Java contains the following packages:
Package oracle.i18n.lcsd
provides classes to automatically detect and recognize language and character set based on text input. Language is based on ISO; encoding is based on IANA or Oracle character sets. It includes the following classes:
LCSDetector
: Contains methods to automatically detect and recognize language and character set based on text input.LCSDResultSet
: The LCSDResultSet
class is for storing the result generated by LCSDetector
. Methods in this class can be used to retrieve specific information from the result.Package oracle.i18n.net
provides Internet-related data conversions for globalization. It includes the following classes:
CharEntityReference
: A utility class to escape or unescape a string into character reference or entity reference formCharEntityReference.Form
: A form parameter class that specifies the escaped formPackage oracle.i18n.Servlet
enables JSP and JavaServlet to have automatic locale support and also returns the localized contents to the application. It includes the following classes:
ApplicationContext
: An application context class that governs application scope operation in the frameworkLocalizer
: An all-in-one object class that enables access to the most commonly used globalization informationServletHelper
: A delegate class that bridges between Java servlets and globalization objectsPackage oracle.i18n.text
provides general text data globalization support. It includes the following classes:
OraCollationKey
: A class which represents a String
under certain rules of a specific OraCollator
objectOraCollator
: A class to perform locale-sensitive string comparison, including linguistic collation and binary sortingOraDateFormat
: An abstract class to do formatting and parsing between datetime and string locale. It supports Oracle datetime formatting behavior.OraDecimalFormat
: A concrete class to do formatting and parsing between number and string locale. It supports Oracle number formatting behavior.OraDecimalFormatSymbol
: A class to maintain Oracle format symbols used by Oracle number and currency formattingOraNumberFormat
: An abstract class to do formatting and parsing between number and string locale. It supports Oracle number formatting behavior.OraSimpleDateFormat
: A concrete class to do formatting and parsing between datetime and string locale. It supports Oracle datetime formatting behavior.Package oracle.i18n.util
provides general utilities for globalization support. It includes the following classes:
LocaleMapper
: Provides mappings between Oracle locale elements and equivalent locale elements in other vendors and standardsOraDisplayLocaleInfo
: A translation utility class that provides the translations of locale and attributesOraLocaleInfo
: An Oracle locale class that includes the language, territory, and collator objectsOraSQLUtil
: An Oracle SQL Utility class that includes some useful methods of dealing with SQLThe GDK for PL/SQL includes the following PL/SQL packages:
UTL_I18N
is a set of PL/SQL services that help developers to build globalized applications. The UTL_I18N
PL/SQL package provides the following functions:
UTL_LMS
retrieves and formats error messages in different languages.
Cause: An invalid or unsupported sorting rule name was specified.
Action: Choose a valid sorting rule name and check the Globalization Support Guide for the list of sorting rule names.
Cause: A functional-driven sorting rule name was specified.
Action: Choose a valid sorting rule name and check the Globalization Support Guide for the list of sorting rule names.
Cause: A valid sorting rule was specified, but the associated data file was not found.
Action: Make sure the GDK jar files are correctly installed in the Java application.
Cause: Binary sorting for the specified character set is not supported.
Action: Check the Globalization Support Guide for a character set that supports binary sort.
Cause: An invalid comparison strength level was specified.
Action: Choose a valid comparison strength level from the list -- PRIMARY, SECONDARY or TERTIARY.
Cause: An invalid composition level setting was specified.
Action: Choose a valid composition level from the list -- NO_COMPOSITION or CANONICAL_COMPOSITION.
Cause: The program attempted to use a character in the Oracle character set that cannot be mapped to Unicode.
Action: Write a separate exception handler for the invalid character, or call the withReplacement method so that the invalid character can be replaced with a valid replacement character.
Cause: The program attempted to use an Unicode character that cannot be mapped to a character in the Oracle character set.
Action: Write a separate exception handler for the invalid character, or call the withReplacement method so that the invalid character can be replaced with a valid replacement character.
Cause: The specified string literal in the date format was too long.
Action: Use a shorter string literal in the date format.
Cause: The date format pattern was too long.
Action: Use a shorter date format pattern.
Cause: An illegal date range was specified.
Action: Make sure that date is in the specified range 0 - 3439760.
Cause: This is an internal error.
Action: Contact Oracle Support Services.
Cause: The same format code was used more than once in the format pattern.
Action: Remove the redundant format code.
Cause: Both the Julian date and the day of the year were specified.
Action: Remove either the Julian date or the day of the year.
Cause: The year format code appeared more than once.
Action: Remove the redundant year format code.
Cause: The hour format code appeared more than once.
Action: Remove the redundant hour format code.
Cause: AM/PM was specified along with A.M./P.M.
Action: Use either AM/PM or A.M./P.M; do not use both.
Cause: BC/AD was specified along with B.C./A.D.
Action: Use either BC/AD or B.C./A.D.; do not use both.
Cause: The month format code appeared more than once.
Action: Remove the redundant month format code.
Cause: The day of the week format code appeared more than once.
Action: Remove the redundant day of the week format code.
Cause: HH24 was specified along with the meridian indicator.
Action: Use either the HH24 or the HH12 with the meridian indicator.
Cause: The signed year was specified along with BC/AD.
Action: Use either the signed year or the unsigned year with BC/AD.
Cause: A format code appeared in a date input format.
Action: Remove the format code.
Cause: An unsupported format code was specified.
Action: Correct the format code.
Cause: An invalid era format code was specified for the calendar.
Action: Remove the era format code or use anther calendar that supports the era.
Cause: An incomplete date format pattern was specified.
Action: Rewrite the format pattern to cover the entire input string.
Cause: An incompatible year was specified for the Julian date.
Action: Make sure that the Julian date and the year are not in conflict.
Cause: An incompatible day of year was specified for the Julian date.
Action: Make sure that the Julian date and the day of the year are not in conflict.
Cause: An incompatible month was specified for the Julian date.
Action: Make sure that the Julian date and the month are not in conflict.
Cause: An incompatible day of the month was specified for the Julian date.
Action: Make sure that the Julian date and the day of the month are not in conflict.
Cause: An incompatible day of the week was specified for the Julian date.
Action: Make sure that the Julian date and the day of week are not in conflict.
Cause: The specified hour and the seconds in the day were not compatible.
Action: Make sure the hour and the seconds in the day are not in conflict.
Cause: The specified minutes of the hour and the seconds in the day were not compatible.
Action: Make sure the minutes of the hour and the seconds in the day are not in conflict.
Cause: The specified seconds of the minute and the seconds in the day were not compatible.
Action: Make sure the seconds of the minute and the seconds in the day are not in conflict.
Cause: An illegal date for the month was specified.
Action: Check the date range for the month.
Cause: Too many format codes were specified.
Action: Remove unused format codes or specify a longer value.
Cause: An illegal year was specified.
Action: Specify the year in the specified range.
Cause: Cause: An illegal quarter was specified.
Action: Action: Make sure that the quarter is in the specified range.
Cause: An illegal month was specified.
Action: Make sure that the month is between 1 and 12 or has a valid month name.
Cause: An illegal week of the year was specified.
Action: Make sure that the week of the year is in the specified range.
Cause: An illegal week of the month was specified.
Action: Make sure that the week of the month is in the specified range.
Cause: An illegal day of the week was specified.
Action: Make sure that the day of the week is between 1 and 7 or has a valid day name.
Cause: An illegal day of the month was specified.
Action: Make sure that the day of the month is in the specified range.
Cause: An illegal day of the year was specified.
Action: Make sure that the day of the year is in the specified range.
Cause: An illegal hour was specified.
Action: Make sure that the hour is in the specified range.
Cause: An illegal hour was specified.
Action: Make sure that the hour is in the specified range.
Cause: Cause: An illegal minute was specified.
Action: Action: Make sure the minute is in the specified range.
Cause: An illegal second was specified.
Action: Make sure the second is in the specified range.
Cause: An illegal second in the day was specified.
Action: Make sure second in the day is in the specified range.
Cause: An illegal Julian date was specified.
Action: Make sure that the Julian date is in the specified range.
Cause: Neither AM/A.M. nor PM/P.M. was specified in the format pattern.
Action: Specify either AM/A.M. or PM/P.M.
Cause: Neither BC/B.C. nor AD/A.D. was specified in the format pattern.
Action: Specify either BC/B.C. or AD/A.D.
Cause: An illegal time zone was specified.
Action: Specify a valid time zone.
Cause: A non-numeric character was found where a numeric character was expected.
Action: Make sure that the character is a numeric character.
Cause: A non-alphabetic character was found where an alphabetic was expected.
Action: Make sure that the character is an alphabetic character.
Cause: An illegal week of the year was specified.
Action: Make sure that the week of the year is in the specified range.
Cause: The string literals in the input were not the same length as the literals in the format pattern (with the exception of the leading whitespace).
Action: Correct the format pattern to match the literal. If the "FX" modifier has been toggled on, the literal must match exactly, with no extra whitespace.
Cause: The numeric value did not match the length of the format item.
Action: Correct the input date or turn off the FX or FM format modifier. When the FX and FM format codes are specified for an input date, then the number of digits must be exactly the number specified by the format code. For example, 9 will not match the format code DD but 09 will.
Cause: An unsupported year for the current calendar was specified.
Action: Check the Globalization Support Guide to find out what years are supported for the current calendar.
Cause: The specified date was out of range for the calendar.
Action: Specify a date that is legal for the calendar.
Cause: An illegal era was specified.
Action: Make sure that the era is valid.
Cause: This is an internal error.
Action: Contact Oracle Support Services.
Cause: An invalid interval was specified.
Action: Specify a valid interval.
Cause: The specified leading precision of the interval was too small to store the interval.
Action: Increase the leading precision of the interval or specify an interval with a smaller leading precision.
Cause: Reserved.
Action: Reserved.
Cause: The specified intervals and datetimes were not mutually comparable.
Action: Specify a pair of intervals or datetimes that are mutually comparable.
Cause: The specified number of seconds was greater than 59.
Action: Specify a value for the seconds to 59 or smaller.
Cause: Reserved.
Action: Reserved.
Cause: The specified leading precision of the interval was too small to store the interval.
Action: Increase the leading precision of the interval or specify an interval with a smaller leading precision.
Cause: The hour in the time zone must be between -12 and 13.
Action: Specify a time zone hour between -12 and 13.
Cause: The minute in the time zone must be between 0 and 59.
Action: Specify a time zone minute between 0 and 59.
Cause: A year must be at least -4713.
Action: Specify a year that is greater than or equal to -4713.
Cause: This is an internal error.
Action: Contact Oracle Support Services.
Cause: The specified field was not found in the datetime or interval.
Action: Make sure that the specified field is in the datetime or interval.
Cause: The hh25 field must be between 0 and 24.
Action: Specify an hh25 field between 0 and 24.
Cause: The fractional second must be between 0 and 999999999.
Action: Specify a value for fractional second between 0 and 999999999.
Cause: The time zone region ID specified was invalid.
Action: Contact Oracle Support Services.
Cause: The specified region name cannot be found.
Action: Contact Oracle Support Services.
Cause: Reserved.
Action: Reserved.
Cause: This is an internal error.
Action: Contact Oracle Support Services.
Cause: An illegal object type was specified.
Action: Use a supported object type.
Cause: An illegal format style was specified.
Action: Choose a valid format style.
Cause: The format pattern cannot be null.
Action: Provide a valid format pattern.
Cause: An illegal number format code was specified.
Action: Correct the number format code.
Cause: An invalid number was specified.
Action: Correct the input.
Cause: Reserved.
Action: Reserved.
Cause: This is an internal error.
Action: Contact Oracle Support Services.
Cause: Extra data was found in the date format pattern while the program attempted to truncate or round dates.
Action: Check the syntax of the date format pattern.
Cause: An illegal precision specifier was specified.
Action: Use a valid precision specifier.
Cause: The character set data file for WE8ISO8859P1 was not installed.
Action: Make sure the GDK jar files are installed properly in the Java application.
Cause: An invalid hexadecimal string was included in the HTML/XML data.
Action: Make sure the string includes the hexadecimal character in the form of &x[0-9A-Fa-f]+;.
Cause: An invalid decimal string was found in the HTML/XML data.
Action: Make sure the string includes the decimal character in the form of &[0-9]+;.
Cause: An invalid character entity was found in the HTML/XML data.
Action: Use a valid character entity value in HTML/XML data. See HTML/XML standards for the registered character entities.
Cause: An invalid Quoted-Printable data was found in the data.
Action: Make sure the input data has been encoded in the proper Quoted-Printable form.
Cause: An invalid MIME header format was specified.
Action: Check RFC 2047 for the MIME header format. Make sure the input data conforms to the format.
Cause: An invalid character in the form of %FF was found when a URL was being decoded.
Action: Make sure the input URL string is valid and has been encoded correctly; %FF needs to be a valid hex number.
Cause: The class of key object in the user-defined locale to character set mapping table was not java.util.Locale.
Action: When you construct the Map object for the user-defined locale to character set mapping table, specify java.util.Locale for the key object.
Cause: The class of value object in the user-defined locale to character set mapping table was not java.lang.String.
Action: When you construct the Map object for the user-defined locale to character set mapping table, specify java.lang.String for the value object.
Cause: An invalid regular expression was specified for the match pattern in the rewrite rule.
Action: Make sure the match pattern for the rewriting rule uses a valid regular expression.
Cause: An invalid character set name was specified.
Action: Specify a valid character set name.
Cause: The default application locale was not included in the supported locale list.
Action: Include the default application locale in the supported locale list or change the default locale to the one that is in the list of the supported locales.
Cause: The rewriting rule parameter was not a String array with three elements.
Action: Make sure the rewriting rule parameter is a String array with three elements. The first element represents the match pattern in the regular expression, the second element represents the result pattern in the form specified in the JavaDoc of ServletHelper.rewriteURL, and the third element represents the Boolean value "True" or "False" that specifies whether the locale fallback operation is performed or not.
Cause: The class of key object in the user-defined parameter name mapping table was not java.lang.String.
Action: When you construct the Map object for the user-defined parameter name mapping table, specify java.lang.String for the key object.
Cause: The class of value object in the user-defined parameter name mapping table was not java.lang.String.
Action: When you construct the Map object for the user-defined parameter name mapping table, specify java.lang.String for the value object.
Cause: An invalid character was included in the parameter name.
Action: Make sure the parameter name is in the form of [a-z][a-z0-9]*.
Cause: Despite the attribute "scope" being set in the tag, the attribute "var" was not specified.
Action: Specify the attribute "var" for the name of variable.
Cause: The "param" tag was not nested inside a "message" tag.
Action: Make sure the tag "param" is inside the tag "message".
Cause: An invalid "scope" value was specified.
Action: Specify a valid scope as either "application," "session," "request," or "page".
Cause: The specified date format style was invalid.
Action: Specify a valid date format style as either "default," "short," or "long"
Cause: An unsupported IANA character set name was specified.
Action: Specify the IANA character set that has a corresponding Oracle character set.
Cause: An invalid parameter name was specified in the user-defined parameter mapping table.
Action: Make sure the specified parameter name is supported. To get the list of supported parameter names, call LocaleSource.Parameter.toArray.
Cause: The class of key object in the user-defined message bundle mapping table was not "java.lang.String."
Action: When you construct the Map object for the user-defined message bundle mapping table, specify java.lang.String for the key object.
Cause: The class of value object in the user-defined message bundle mapping table was not "java.lang.String."
Action: When you construct the Map object for the user-defined message bundle mapping table, specify java.lang.String for the value object.
Cause: An invalid character was included in the specified ISO locale names in the GDK application configuration file.
Action: Make sure the ISO locale names include only valid characters. A typical name format is an ISO 639 language followed by an ISO 3166 country connected by a dash character; for example, "en-US" is used to specify the locale for American English in the United States.
Cause: The specified profile was not found.
Action: Make sure the GDK jar files are installed properly in the Java application.
Cause: The IANA character set specified was either invalid or did not have a corresponding Oracle character set.
Action: Check that the IANA character is valid and make sure that it has a corresponding Oracle character set.
Cause: The ISO language specified was either invalid or did not have a corresponding Oracle language.
Action: Check to see that the ISO language specified is either invalid or does not have a corresponding Oracle language.
Cause: A character set filter and a language filter were set at the same time in a LCSDetector object.
Action: Set only one of the two -- character set or language.
Cause: The reset method was not invoked before a different type of data source was used for a LCSDetector object.
Action: Call LCSDetector.reset to reset the detector before switching to detect other types of data source.
Cause: The Oracle character was either invalid or incomplete and could not be mapped to an Unicode value.
Action: Write a separate exception handler for the invalid character, or call the withReplacement method so that the invalid character can be replaced with a valid replacement character.
Cause: The Unicode character did not have a counterpart in the Oracle character set.
Action: Write a separate exception handler for the invalid character, or call the withReplacement method so that the invalid character can be replaced with a valid replacement character.