For example, to translate an entity called Customer, with the properties Name and Address, into the language PT_BR, it would be enough to create the following message package “messages_pt_BR.properties”:
Could this translation method be used to automatically translate elements (label and content) created from an SQL query into a PDF report, generated at runtime? I couldn’t understand a way to do this using the “messages.properties” or “messages_pt_BR.properties” file. If there is a way to do this, could you give an example?
The question was “whether it would be possible to use only the Messages bean, native to Cuba Studio, to translate the report elements and their respective values”. But as you explained, another form is needed (like a Groovy script or in our case an SQL script).
The solution we found to translate elements (fields and values) of a report uses a component that we developed for translation at Tupy, and it is a SQL Dataset. To do this, we load the data (for example, field “model_type” with the value “explosion engine”) from a specific table (for example, “equipment”), and its corresponding translation (the value “explosion engine”) from a translation correlation table, and then we display it in a report, passing the language as a query parameter (for example, pt_br for Brazilian Portuguese).
So, if it is necessary to translate the field names and their values in the reports into another language (such as Spanish, for example), we just need to register the field names and their values in the new language in the database.
This approach we used serves us well: We leave the Messages bean for translating messages and fields displayed on the screen, and use our component to translate SQL Dataset elements used in reports.