Localizing a component to a non-Unicode language

The following example demonstrates how to localize a component to a double-byte, extended character language.

If you want to use this example as a learning exercise but do not have non-Unicode text of your own to deploy, you can machine-translate your English-language file and use that text in step 5 below.

To localize your portlet to a non-Unicode language (such as Japanese):

  1. Within your portlet, create a file PluginResource_<locale-code>.properties.native at the appropriate location. For example, if you are working with Japanese, the file name would be PluginResource_ja.properties.native.
  2. Commit both the .native and .properties file to your portlet. The .properties file is used by the portlet, but because that file uses escaped Unicode notation, it is extremely hard for humans to read. It is easier to make any necessary changes in the .native file.
  3. Open the .native file in an encoding- and character-set-aware text editor such as Notepad++. Make sure the .native file uses UTF-8 as its encoding and Shift-JIS as its character set.
  4. Copy the contents of the English resource bundle into the .native file.
  5. Within your text editor, using your translation service, replace the English values with the Japanese values.
  6. Save the file.
  7. From the command line, run Java's native2ascii converter. This tool is typically included in the JDK. In the encoding argument, specify Shift_JIS as the character set, your .native file as the input, and your final .properties file as the output.
    native2ascii -encoding Shift_JIS PluginResource_ja.properties.native PluginResource_ja.properties
  8. Commit both the .native and .properties file to your portlet. The .properties file is used by the portlet, but uses escaped Unicode notation, which is hard to read. The .native file is easier to modify.