We are localizing the user-interface text for web applications running Java 5 The type used by how we output messages that are defined in property files -
Some messages include a placeholder that will be used for example:
search.summary = {0} for your search {1} items
The message format is upset, even though it is common in English text, a single quote is a special character. You have to type two for a single single quote:
warning.item = This item is not valid {0}.
However, do not include three-fourth placeholder of 1000 or so messages of the application, that means we can directly output them, save the message format, and single quotes alone You can leave:
help.url = Web page URL
Question: For all messages, Should use message format for consistent syntax or avoid message format; Yes we can, so most messages do not need to be avoided?
Note that API documents for MessageFormat accept the problem and suggest a non-solution:
Message format pattern The rules for using quotation marks within are unfortunately some deceptive. Specifically, it is not always clear for the locals whether the single quote should be doubled or not. Be sure to inform local owners about the rules, and tell them (for example, by using the comments in the source bundle source files) that the strings will be processed by MessageFormat.
Just write the implementation of your own message format without this annoying feature. You can see the code.
They have a version of their message format, which can be used as the following:
logger.debug ("temperature set {} was old" }. ", T, old T);
An empty placeholder can be used with default ordering and numbers for some localization cases where different language changes the word or part of the sentence.
Comments
Post a Comment