Custom jrxml templates: pass REPORT_LOCALE and REPORT_RESOURCE_BUNDLE so $R{key} captions and number/date formats follow the user's locale
@danchanka is already working on this.
Since Oct 16, 2026.
Assessment
This issue has not been assessed yet.
Description
Summary
A custom jrxml template has no way to get localized captions from the platform. The standard JasperReports mechanism for this - $R{key} text fields resolved through a resource bundle - does work today with the application's own bundle on the classpath (verified on 7.0-SNAPSHOT with resourceBundle="MyCompanyResourceBundle" on the report: $R{Opening_balance} prints «Начальный остаток» / "Opening balance" / „Saldo otwarcia”, msg($R{...}, args) works too), but the bundle is resolved by the default locale of the JVM that fills the report, not by the locale of the user, because the platform passes neither REPORT_LOCALE nor REPORT_RESOURCE_BUNDLE to JasperFillManager.fillReport. The number and date patterns of the template (#,##0.00, yyyy-MM-dd etc.) follow the JVM locale for the same reason.
So an application whose users pick their own language (Authentication.language) cannot have one localized template: today the only way is to pass every caption from the form as a value (PROPERTIES captionDebit = 'Debit', ... and $F{captionDebit} in the template), which is a lot of noise in the form and makes the template depend on the names of helper fields.
Where
api/src/main/java/lsfusion/interop/form/print/ReportGenerator.java: JasperFillManager.fillReport(report, childParams, source) - the parameters hold only the <id>_report / <id>_source / <id>_params entries of the subreports and REPORT_VIRTUALIZER.
Proposed solution
- When the server builds
ReportGenerationData(FormReportManager), take the locale of the current user from the context, collect the$R{key}references of the report designs (a regular expression over the expression texts is enough), localize every key with the platform localizer across all bundles (DefaultLocalizer.localizeKey(key, locale), i.e. the project bundles and the platform ones alike), and put the resultingMap<String, String>and the locale into the generation data. - In
ReportGenerator, before filling, putJRParameter.REPORT_LOCALE= that locale andJRParameter.REPORT_RESOURCE_BUNDLE= aListResourceBundleover that map into the parameters (for the top report and the subreports).
Then a template needs no resourceBundle attribute at all: $R{Debit} is localized exactly like a form caption '{Debit}', the desktop client does not need the application bundles (it receives the map), number and date patterns are formatted in the user's locale, and sentences with substitutions can be ordinary MessageFormat patterns in the bundle (According to the records of {0} as of {1,date,yyyy-MM-dd} the balance in favour of {2}:) used through msg().
Example
<jasperReport ... name="Invoicing_printReconciliationStatement">
...
<textField><reportElement .../>
<textFieldExpression><![CDATA[$R{Opening_balance}]]></textFieldExpression>
</textField>
<textField><reportElement .../>
<textFieldExpression><![CDATA[msg($R{Balance_in_favour_of}, $F{fullName(c)}, $F{dateTo}, $F{fullName(p)})]]></textFieldExpression>
</textField>
With the keys in MyCompanyResourceBundle[_ru|_pl].properties this prints in the language of the server today and would print in the language of the user with the change above.
- Dominant language
- Java
- Stars
- 214
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lsfusion/platform
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 30/100
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
All issues in lsfusion/platform
Similar issues
-
account assessment course feature lecture
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
app:learninggoalhub enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
PropertyResolver fails on JDK classes with a non-public field named like the propertyPossibly taken @vaibhavgupta443 claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
apache/wicket#1991 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100