Search code examples
multilingualjsreport

Multiple languages capability of Jsreport


I would like to know if jsreport have the ability to translate report to other languages. For example in the data I sent to jsreport to render has language of choice(Germany, Italian,...), can I do anything (setup in template, call external services,etc.) to translate some key texts into those language.

However, this question is about general jsreport current support of multi-languages


Solution

  • This is currently ([email protected]) implemented using resources extension.

    http://jsreport.net/learn/resources

    Resources extension lets you attach multiple JSON data objects to the report template and later conveniently access them using templating engines or in custom scripts. This can be useful to add a general configuration to the template or mainly localize the template...

    The main approach to implement the localization using resources extension:

    1. Upload resource (json data item) for each language into jsreport studio and name it with language prefix - en-myresource, de-myresource
    2. Associate data items inside resources section to the report template
    3. Use $localizedResource to reach the localized values in the templating engine, for example {{:$localizedResource.invoice.title}}
    4. Specify the particular language to be used in the API request: { template: {...}, options: { language: "de" } }

    Example: https://playground.jsreport.net/studio/workspace/VkLWfMyMb/7