messageformat

Java internationalization (i18n) with proper plurals

我们两清 提交于 2019-12-02 15:48:43
I was going to use Java's standard i18n system with the ChoiceFormat class for plurals, but then realized that it doesn't handle the complex plural rules of some languages (e.g. Polish). If it only handles languages that resemble English, then it seems a little pointless. What options are there to achieve correct plural forms? What are the pros and cons of using them? Paweł Dyda Well, you already tagged the question correctly, so I assume you know thing or two about ICU . With ICU you have two choices for proper handling of plural forms: PluralRules , which gives you the rules for given Locale

How do I format a long integer as a string without separator in Java?

寵の児 提交于 2019-11-29 20:54:29
Simple question, but I'll bet that asking on here will probably be more straight forward than trying to understand the documentation for MessageFormat : long foo = 12345; String s = MessageFormat.format("{0}", foo); Observed value is "12,345". Desired value is "12345". Rob H Just use Long.toString(long foo) MessageFormat.format("{0,number,#}", foo); The shortest way is long foo = 12345; String s = ""+foo; As an alternative String.format and java.util.Formatter might work for you as well... You could try: String s = new Long(foo).toString(); 来源: https://stackoverflow.com/questions/1942118/how

Can I escape braces in a java MessageFormat?

旧时模样 提交于 2019-11-29 05:23:44
I want to output some braces in a java MessageFormat. For example I know the following does not work: MessageFormat.format(" public {0} get{1}() {return {2};}\n\n", type, upperCamel, lowerCamel); Is there a way of escaping the braces surrounding "return {2}"? You can put them inside single quotes e.g. '{'return {2};'}' See here for more details. Bombe Wow. Surprise! The documentation for MessageFormat knows the answer: Within a String , "''" represents a single quote. A QuotedString can contain arbitrary characters except single quotes; the surrounding single quotes are removed. An

How do I format a long integer as a string without separator in Java?

余生长醉 提交于 2019-11-28 16:33:59
问题 Simple question, but I'll bet that asking on here will probably be more straight forward than trying to understand the documentation for MessageFormat : long foo = 12345; String s = MessageFormat.format("{0}", foo); Observed value is "12,345". Desired value is "12345". 回答1: Just use Long.toString(long foo) 回答2: MessageFormat.format("{0,number,#}", foo); 回答3: The shortest way is long foo = 12345; String s = ""+foo; 回答4: As an alternative String.format and java.util.Formatter might work for you

Can I escape braces in a java MessageFormat?

我的未来我决定 提交于 2019-11-27 22:54:50
问题 I want to output some braces in a java MessageFormat. For example I know the following does not work: MessageFormat.format(" public {0} get{1}() {return {2};}\n\n", type, upperCamel, lowerCamel); Is there a way of escaping the braces surrounding "return {2}"? 回答1: You can put them inside single quotes e.g. '{'return {2};'}' See here for more details. 回答2: Wow. Surprise! The documentation for MessageFormat knows the answer: Within a String , "''" represents a single quote. A QuotedString can

How to print multiple header lines with MessageFormat using a JTable

蹲街弑〆低调 提交于 2019-11-26 23:10:40
问题 I have a table called table and its filled with data, I also have a MessageFormat header I want to use as a header to print the JTable this is the MessageFormat : MessageFormat header = new MessageFormat("Product: " + task.getProductName() + " Job: " + task.getJobNumber() + " Task: " + task.getTaskID() ); I want to print 3 lines in the header, one for Product, Job and Task the way I print this table is like so: table.print(JTable.PrintMode.FIT_WIDTH, header, null); I can't seem to figure out