Prepare the translations. Feature Labels and Internationalization

2-16 Oracle Fusion Middleware Users Guide for Oracle MapViewer For frequently used themes whose base data is static or read-only, specify caching ALL for the best performance. This causes MapViewer, when it first accesses the theme definition, to fetch all the features including spatial data, attribute data, and styling information associated with them and cache them in the MapViewer memory, creating an in-memory R-tree for the theme’s spatial data. All subsequent requests requiring that theme occur locally instead of going to the database. If the caching attribute value is NORMAL the default, each time a map involving that theme is requested, MapViewer queries the database to get the spatial data and any associated attribute data. However, if any of the spatial geometry data, as referenced by rowid or a user-specified key column, has already been cached, the unpickling process the conversion from the raw database geometry format to a Java geometry object is skipped. Still, if memory is not an issue and if a frequently used theme can completely fit in the cache, you should specify caching ALL, to eliminate virtually all database access for that theme after the initial loading. Because the MapViewer spatial data cache is global, all predefined themes that are accessed by MapViewer compete for a global fixed-sized memory cache. The cache resides completely in memory, and you can specify the maximum size of the cache as explained in Section 1.5.2.6 . When the cache limit is reached, older cached data is removed from the cache to make room for the most recently accessed data, except that data for themes specified with caching ALL is not removed from the cache, and MapViewer does not requery the database for these themes. Caching is currently disabled for predefined annotation and custom geometry themes. For custom geometry themes, you can implement a caching mechanism in your provider implementation. However, for each request, a new instance of your provider is created; and if you implement a local caching mechanism, it will be lost.

2.3.1.6 Feature Labels and Internationalization

MapViewer includes support for translated theme labels. Typically with a predefined MapViewer theme, you can specify a label column that will provide all the text strings for labeling each feature of the theme. These text strings are string values stored in the database table column, in a specific language such as English. However, you can also supply different translations of these stored string values by using a resource bundle. When such translated text strings are available, you can instruct MapViewer to label the features of a theme using a specific language or locale. The steps for supplying translations and instructing MapViewer to label a theme using a specific user language are as follows:

1. Prepare the translations.

A typical MapViewer predefined geometry theme gets all the underlying data from a table. You can specify one of the string type columns as the labeling column for this theme. This is called the label column. When a label column needs to be translated into different languages, you extract all the values from the table, and store them in a properties file, such as StringResources.properties. Note that file name StringResources.properties assumes that the extracted texts are all in English. If they are not, then the properties file name needs to follow a convention where the language code, and an optional region or country code, is a suffix in the file name. For example, StringResources_ Note: Only predefined geometry themes support resource bundles at this time. MapViewer Concepts 2-17 fr.properties will contain French translations only, while StringResources_zh_CN.properties is for simplified Chinese. A properties file is a plain text file that follows a very simple format. For example, a simple StringResources.properties file might contain the following: This is the English version of the strings. California = California Nevada = Nevada Montana = Montana The first line is a comment, and starts with the character. Each subsequent line contains one pair of key first string and value second string. The keys come directly from the label column, whereas the values are corresponding translations. Because this particular file contains the default English text strings, the key and the value translation are the same in each case. Note that the keys should always be in English. From this default properties file, your translation specialists should create a set of property files, one file for each translation. Using the preceding simple example, the translated file for simplified Chinese StringResources_zh_ CN.properties should look like the following, in which the value of each key has been replaced by the Chinese translation of the key, encoded as a Unicode string: This is the Chinese version of the strings. California = \u6CA1\u6709\u8981\u5448\u73B0\u7684\u4E3B\u9898\u3002 Nevada = \u65E0\u6CD5\u52A0\u8F7D\u4E3B\u9898\u3002 Montana = \u65E0\u6CD5\u52A0\u8F7D\u6837\u5F0F\u3002 The default properties file, StringResouces.properties, plus all the language specific files that share the same file name except for the language and region suffixes collectively form what is called a resource bundle. In this case the resource bundle is named StringResources. You can name your resource bundles with any name you like, but different bundles containing different set of keys should always use different base names. For more information about Java resource bundles and properties files, see the Java language documentation. 2. Supply the translated text strings as a Java Resource Bundle, which can be based on either Java resource classes or plain properties files. After all the label text strings have been translated, you must place all the files the resource bundle in the MapViewer CLASSPATH so that MapViewer can find these files at run time. Typically, you can use the MapViewer WEB-INFclasses folder: copy all the files including the base StringResources.properties and language-specific files such as StringResources_fr.properties and StringResources_zh_CN.properties into this folder. Note that if you place all the files of a resource bundle into a subfolder under WEB-INFclasses, then the name of the resource bundle as known to MapViewer will need to be prefixed with this subfolder name. This is similar to how one places a Java class in a directory structure that follows the package names. For example, if you put all the StringResources.properties files in WEB-INFclassesi18n, then later when you register the resource bundle with MapViewer, the actual name of your resource bundle should be i18n.StringResources. 3. Specify the name of the resource bundle in the theme definition by registering the resource bundle with MapViewer. 2-18 Oracle Fusion Middleware Users Guide for Oracle MapViewer For MapViewer to find your translated classes, you must specify the complete name of your resource bundle in the theme definition. The easiest way to do this is with the Map Builder utility, specifying the resource bundle name as the Translation Class in the Advanced Parameters pane of the theme editor. Figure 2–6 shows StringResources being specified for the Translation Class. Figure 2–6 Specifying a Resource Bundle for a Theme As mentioned in the preceding step, if your resource bundle files are located in a subfolder of , then the subfolder name must the base name of your resource bundle, separated by a period, as if the resource bundle files were Java classes in a package. 4. Specify a language parameter when requesting a map or theme. Specify the preferred language for each map request the Oracle Maps JavaScript API described in Section 8.4 or the XML map request API described in Chapter 3 . ■ In JavaScript code, specify the label language code in the call to the MVThemeBasedFOI class. The following example causes the FOI theme to display its labels in simplified Chinese: themebasedfoi = new MVThemeBasedFOIthemebasedfoi1,mvdemo.theme_demo_ states; themebasedfoi.setLabelLanguageCodezh-cn ; themebasedfoi.enableLabelstrue; With the setLabelLanguageCodelang_code method, you can specify a language code so that MapViewer labels the features using the text strings for MapViewer Concepts 2-19 the specified language, which must be a 2 letter language code such as zh, followed optionally a hyphen - and a 2-letter country code such as zh-cn. The language codes are defined by the ISO 639 standards and are listed at several Web sites, such as http:www.loc.govstandardsiso639-2phpEnglish_ list.php . If no translated text strings for the specified language code are found, the English text strings or whatever the default strings are for the theme will be used for labeling. ■ In an XML map request, specify the language in the lang attribute. The following example causes the labels to be displayed in simplified Chinese: map_request title=Oracle LBS MAP basemap=demo_map datasource = mvdemo width=640 height=480 lang=zh-CN format=PNG_STREAM center size=5.15 geoFeature geometricProperty typeName=center Point coordinates-122.2615, 37.5266coordinates Point geometricProperty geoFeature center map_request Only language codes and country codes specified by the ISO 639 standards can be used as possible lang values. If an optional country code is used, it must be connected to the language code by a hyphen -. Country codes and language codes are not case sensitive. If the lang attribute is specified as part of the XML map request, every theme rendered to the result map it checked to see if it has an associated resource bundle. If a theme does not have an associated resource bundle, or the translated text strings for the specified language cannot be found, the default values those stored in the table column are used. If the lang attribute is not specified as part of the XML map request, the default text string values those stored in the table column are always used, regardless of which locale in effect for MapViewer itself or rather, its containing JVM.

2.3.2 JDBC Themes