---
name: localization
description: Localize JasperReports output with resource bundles, report locales and time zones, locale-aware date and number patterns, Unicode text and right-to-left scripts. Use when labels are untranslated or in the wrong language, dates or numbers format for the wrong locale or time zone, translations are missing, or Arabic or Hebrew output must read right to left; not for translating an application UI without reports.
---
# Localize reports
## Establish the localization contract
Identify the exact engine/Java versions, every supported locale and its fallback, the time zone each audience expects, which values are instants and which are local dates, the bundle location and encoding, the scripts and directions to render and the export formats. Ask for the expected text of at least one label, one date and one amount per locale instead of guessing.
## Workflow
1. Pass the locale and time zone on every fill. Set `REPORT_LOCALE` and `REPORT_TIME_ZONE` in the parameters map from the request or user profile. Without them, the fill uses the JVM defaults, so a server's locale or `UTC` zone silently changes labels, separators and dates. The same instant can print a different calendar day in another zone.
2. Translate labels through a bundle. Set `resourceBundle="i18n/statement"` on the report, keep `statement.properties` as the complete base and add `statement_de.properties` and other locales, then use `$R{key}` for labels and `msg($R{greeting}, $F{name})` for parameterized text. Bundles are loaded from the classpath; Java 9 and later read `.properties` bundles as UTF-8.
3. Know the fallback chain. A regional locale such as `de-CH` falls back to `de`, and a key missing from a locale file falls back to the base file. For a locale without its own file, Java first tries the JVM default locale, so on a German server a French request prints German labels with French dates and numbers. To prevent that, load the bundle with `ResourceBundle.Control.getNoFallbackControl(ResourceBundle.Control.FORMAT_PROPERTIES)` and pass it in `REPORT_RESOURCE_BUNDLE`, or make the supported locales explicit.
4. Choose the missing-key policy. A key missing from every bundle prints `null` by default. Set `whenResourceMissingType="Error"` on the report to fail with `MissingResourceException` in tests and CI, or `Key`/`Empty` when output must never show `null`; do not ship a template that silently prints `null`.
5. Format values with patterns, not string concatenation. Use `pattern="#,##0.00"` or a date pattern on the text field so the fill formats with `REPORT_LOCALE` and `REPORT_TIME_ZONE`. Some locales use non-breaking or narrow no-break group separators, and Arabic locales may print Arabic-Indic digits, depending on the JDK locale data.
6. Leave room for longer text. A fixed-size field silently cuts longer translations or dates; use `textAdjust="StretchHeight"` or wider fields, and test the longest locale.
7. Lay out right-to-left text. Text direction is detected from the text itself: in the tested 7.1.1 runtime, text elements have no `runDirection` attribute, and Arabic text prints right to left while staying left aligned. Align or mirror it with a conditional style on the locale, for example `"ar".equals($P{REPORT_LOCALE}.getLanguage())` setting `hTextAlign="Right"`. Use an embedded font with the needed glyphs (see `styles-fonts`).
## Validate and deliver
Fill with at least two fixed locales and time zones, a regional locale, an unsupported locale on a server with a different default, a missing key and right-to-left text. Assert exact labels, dates and numbers per locale (including special separators), the missing-key result and the text and alignment of right-to-left elements, and extract PDF text with an independent library. Set the JVM default locale and time zone explicitly in tests so results do not depend on the machine. State commands and results, and label any locale, export format or visual right-to-left rendering you could not check as unverified.
## Sources
- [Sample reference](https://jasperreports.sourceforge.net/sample.reference/README.html)
- [Schema reference](https://jasperreports.sourceforge.net/schema.reference.html)
- [API](https://jasperreports.sourceforge.net/api/index.html)
— ‹guest · 2026-11-29› —
این نسخه با نشانهگذاری اختصاصی حساب شما نمایش داده میشود. برای نصب سریع، به تب نصب و راهاندازی بروید.