With use Spring's message taglib for putting strings onto our web pages. This gives us the ability to translate openmrs very easily. If you want to put a string into a jsp page into openmrs you put this spring:message in your jsp:
And then you find the messages.properties file and add this:
And if you're bilingual and not too lazy you find the messages_es.properties file and append this:
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.
Its annoying to have to edit two files to add a simple string. (Most devs only know english and so will only ever edit the one file)
Allow for in-line adding/editing of the translated text by the developer.
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.
However, now if we also create a Firefox Plugin (or any other browser) that looks for any html tag with "openmrstranslate" in the class attribute, the plugin could let the user click on a put in new text. The output of what the translator enters can be saved to a file of their choice. The file is then dropped into openmrs as the messages_en.properties file (or whatever other language).