Ticket #972 (closed Enhancement: fixed)

Opened 8 years ago

Last modified 8 years ago

translating dm4-sign-up module to render labels in german language

Reported by: Malte Owned by:
Priority: Major Milestone: Release 4.8.1
Component: 3rd Party Plugins Version: 4.8
Keywords: Cc: jri, dgf, JuergeN
Complexity: 5 Area: GUI / Usability
Module:

Description

We at Kiezatlas now have the case that we want to translate all labels and messages to users using the sign-up plugin in german language.

At best we would not need to fork the source code but could contribute a german translation (as part of future sign-up module releases).

  • Any hints or tips on how to localize our plugin at best?
  • I guess in java some devs do so using a ".properties" file, am i right?
  • How to localize browser dialogs created by JS?

Thanks for your support!

Change History

comment:1 Changed 8 years ago by jri

I think this is rather straight-forward.

The usual approach is to not hardcode language-specific strings but to look them up by key from a table. You'll have one table per supported language.

To serve the tables to the client you could place them in your plugin's resources/web/... directory, or you could serve them dynamically via your plugin's REST service.

In case you need localization at the server-side as well (e.g. in Thymeleaf templates) see also java.util.ResourceBundle

comment:2 Changed 8 years ago by jri

If you need strings with placeholders consider java.util.Formatter. Argument indexes (1$, 2$, ...) in the format string can be used to deal with language-specific sentence structure.

comment:3 Changed 8 years ago by Malte

Thank you for your comments that was very helpful. And yes, sorry for being unclear, I was explicitly interested around localization approaches in Java (on server side) and your hints lead me to the perfect resource for translating my plugins.

I now build on a specific ResourceBundle? implementation, the PropertiesResourceBundle as i found this resource very helpful: http://docs.oracle.com/javase/tutorial/i18n/resbundle/propfile.html

Furthermore .properties-files seem the way to go for translating java programs as i found some web applications build to support end-users with translating software. These tools speifically support .properties. Thus, for all client side (e.g. JavaScript?) labels and messages i will therefore also aim (and recommend) to build on .properties (when using Java on server-side) and exposing the java.util.Locale specific labels/messages as a simple JSON object via REST.

I now started to translate all message and button labels during the sign-up process from english to german (and plan to add french later on too). Will keep you posted as i make progress.

Thanks also for the hint on using java.util.Formatter, i will try to find a resource explaining this a bit more on translations and dealing with java.util.Locale specific output.

comment:4 Changed 8 years ago by jri

Can we close this ticket?

comment:5 Changed 8 years ago by Malte

Yes, thanks for your help.

comment:6 Changed 8 years ago by Malte

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.