1 / 14

Internationalization and Localization

Internationalization and Localization. Celsina Bignoli bignolic@smccd.net. Internationalization and Localization. internationalization : creating code so that it can be customized for use in different countries and regions ( i18n-ready)

major
Download Presentation

Internationalization and Localization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. InternationalizationandLocalization Celsina Bignoli bignolic@smccd.net

  2. Internationalization and Localization • internationalization: creating code so that it can be customized for use in different countries and regions ( i18n-ready) • localization: adapting i18n-ready software to a particular region(i10n-ready) • translating text to the local language • changing numeric formatting • changing currency symbols • changing date formatting

  3. Per-request Localization Browser User from US Localized UI in English Browser User from China Central Web Server (US) Localized UI in Chinese Internationalized JSP based Web Application Browser User from France Localized UI in French

  4. Locales • represents a specific set of localization requirements • Specified using a string in the following format xx_YY • xx is the language code • YY is the code of the country that uses that language • Examples: en_GB, en_US, es_MX, es_ES

  5. Maintaining Locale Information • On a standalone Java application running on a single system, the locale can be set by the underlying OS • For web applications the locale of the server machine is of no significance • localization must be determined and handled on a per-request basis • Explicit locale determination

  6. Java 2 Resource Bundles • The application does not contain any text strings that might need to be translated • Instead, specific names are given to these strings • A resource bundle is created as a set of property files • Each line in a property file has the following format: <property name> = <property value> • A property file is created for each language supported (app.properties, app_es.properties, app_zh.properties etc) • Property names are the same in each property file, property value is language specific • .properties files are located in WEB-INF/classes

  7. JSTL fmt Library • JSTL tags to support i18n are located in the fmt tag library • This tag library must be included in a JSP page as follow: %@taglib prefix=“fmt” uri=“http://java.sun.com/jsp/jstl/fmt” %

  8. <fmt:setLocale> • sets the locale configuration variable establishing thr locale for all other JSTL actions that rely on it • Syntax: <fmt:setLocale value=“locale” [scope=“page|request|session|application] />

  9. <fmt:bundle> • sets a localization context for actions in its body • The localization context contains a locale and the best match for the specified resource bundle • Syntax: <fmt:bundle basename=“resourceBundleBasename” [prefix=“keyPrefix”]> JSP elements </fmt:bundle>

  10. <fmt:message> • adds the localized message for the specified key to the response buffer or saves it into a scoped variable • Syntax: <fmt:message key=“messageKey” [bundle=“resourceBundle”] [var=“var” [scope=“page|request|session|application]] />

  11. <fmt:formatNumber> • formats a numeric value according to the given locale • Syntax: <fmt:formatDate value=“number” [pattern=“pattern” | [type=“number|currency|percent”] [currencyCode=“currencyCode”] [currencySymbol=“currencySymbol”] [groupingUsed=“true|false”] [minIntegerDigits=“min”] [maxIntegerDigits=“max”] [minFractionDigits=“min”] [maxFractionDigits=“max”] [[var=“var” [scope=“page|request|session|application]] />

  12. <fmt:formatDate> • formats a date and time value according to the given locale • Syntax: <fmt:formatDate value=“dateAndTime” [pattern=“pattern” | [type=“time|date|both”] [dateStyle=“default|short|medium|long|full”] [timeStyle=“default|short|medium|long|full”]] [timeZone=“timeZone”] [[var=“var” [scope=“page|request|session|application]] />

  13. <fmt:timeZone> • establishes the time zone for actions in its body • Syntax: <fmt:timeZone value=“timeZone”> JSP elements </fmt:timeZone>

  14. <fmt:setTimeZone> • sets the time zone configuration variable for all JSTL actions that rely on it. • Syntax: <fmt:setTimeZone value=“timeZone”> [var=“var” [scope=“page|request|session|application]] />

More Related