Should I use java.text.MessageFormat for localised messages without placeholders?

前端 未结 5 2143
北海茫月
北海茫月 2021-02-20 03:55

We are localising the user-interface text for a web application that runs on Java 5, and have a dilemma about how we output messages that are defined in properties files - the k

5条回答
  •  迷失自我
    2021-02-20 04:52

    In my opinion, consistency is important for this sort of thing. Properties files and MessageFormat already have lots of limitations. If you find these troubling you could "compile" your properties files to generate properly-formed ones. But I'd say go with using MessageFormat everywhere. This way, as you maintain the code you don't need to worry about which strings are formatted and which aren't. It becomes simpler to deal with, since you can hand off message processing to a library and not worry about the details at a high level.

提交回复
热议问题