mapfish-print icon indicating copy to clipboard operation
mapfish-print copied to clipboard

Add support for internationalization

Open tsauerwein opened this issue 10 years ago • 2 comments

The recommended way to translate a JasperReports template is to create a properties file for each language (e.g. locale.properties, locale-fr.properties), to set the resourceBundle property in the template and then to use the translated strings with $R{locale.text1} (see JasperReports - Internationalization).

The only problem is that the resource bundle, that is the property files have to be on the class path. We could either add the directories with the print configuration to the class-path or manually load a ResourceBundle instance and pass this instance to the template with JRParameter.REPORT_RESOURCE_BUNDLE (see here).

Related: https://github.com/mapfish/mapfish-print/issues/183

Proposed implementation:

  • Add a property to the YAML configuration to specify the language settings (resource bundle, available languages, default language). When this property is set the parameter JRParameter.REPORT_RESOURCE_BUNDLE will be filled for the report.

E.g.:

  templates:
    A4 landscape: !template
      reportTemplate: simpleReport.jrxml
      attributes:
        i18n: !i18n
          resourceBundle: locales.properties
          languages: ["en", "de", "fr"]
          default: "en"
  • When sending a print request, the language can be set as attribute.

E.g.:

{
  "layout": "A4 landscape",
  "attributes": {
    i18n: {
      lang: "en"
    },
    ...
  }
}

tsauerwein avatar Jun 02 '15 08:06 tsauerwein

any news on this ?

petzlux avatar Jan 27 '16 15:01 petzlux

@petzlux No, this has not been implemented yet.

tsauerwein avatar Feb 03 '16 16:02 tsauerwein