Wiki Spaces

Documentation
Projects
Resources

Get Help from Others

Q&A: Ask OpenMRS
Discussion: OpenMRS Talk
Real-Time: IRC Chat | Slack

Projects

Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Now the text can be is displayed automatically in Spanish if the user has set their locale as Spanish.  If the user is in the English locale or any other, they will see the english translation.

ProblemProblems:

  • Its

...

  • inefficient to have to edit two files to add a simple string.

...

  • Many devs only know english and so will only ever edit the one file

...

  • .
  • When translating message bundles, the translator lacks the context of the message within the application.

Solution:

Allow for in-line adding/editing of the translated text by the developer.

Design

These are separated into mostly independent tasks that can be done by different developers.

Task #1: (Java)

Subclass the default Spring "message" taglib class and allow for text inside of the tag.  The spring.tld file in openmrs tells me that the class is org.springframework.web.servlet.tags.MessageTag.

If that text is entered in the body of the html tag by the developer, use that as the "en" translation in the message taglib class instead of looking in the messages.properties file.

Task #2: (no tech knowledge needed)

Move text from the messages.properties into the body of the spring tags in core.  This is a very tedious task but doesn't require a lot of java knowledge.

Task #3: (scripting knowledge helpful)

Create a shell script or ant script/target that scans the web folder looking for spring:message tags.  The script should take the 'key' from the tag and insert it into the messages.properties file (but only if it doesn't exist in the file already).

The value for the key in the  messages.properties file should be the body content of the spring:message tag in the jsp file

Task #4: (scripting knowledge helpful)

If a volunteer comes along and says "I want to help translate openmrs in Spanish" we typically just given them the english messages.properties and they turn the right side of it into spanish.  However, seeing the text in context is SOO much easier to translate.

It would be awesome to be able to see the codes and then translate right when viewing the page.  We could use a firefox plugin + custom modifications to our custom message tag (see task 1) for this:

There could be a Global Property that can be set to put the OpenmrsMessageTag into "translate mode".  So the text returned from the tag is "<span class="openmrstranslate">Enter the person id</span>.  The webapp will run just as it did before with this new entry.

...

  • Create an OpenMRS JSTL tag for messages – i.e., openmrs:message – allowing us to control the output and enhance messaging within OpenMRS.
    • This can extend the existing spring:message tag; however, we will want to add the ability to output special HTML to support in-line localization as well as allow for locale & message to be specified in the web page.
    • At the same time, we'd like to enhance the utility for referencing messages within Java code to include a locale and message for that locale.
  • Create a module that enables in-line localization.
    • When translation is enabled, render messages in a manner that support in-line changes.
    • Persist those changes back to the message bundles.
  • Create a workflow that ensures that local changes to the message bundles are not lost when OpenMRS is upgraded.

Extra credit:

  • Create a script to identify embedded messages in web pages and code and bring those into the appropriate message bundle(s).
  • Create a script to take the default bundles (i.e., en) and import those messages into web pages and code as the default message.

See Also

  • Jira
    TRUNK-1525
    TRUNK-1525

...