Re: svn commit: r1003459 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilNumber.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r1003459 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilNumber.java

Adam Heath-2
On 10/01/2010 04:56 AM, [hidden email] wrote:

> Author: hansbak
> Date: Fri Oct  1 09:56:20 2010
> New Revision: 1003459
>
> URL: http://svn.apache.org/viewvc?rev=1003459&view=rev
> Log:
> add role set for 'th' locale into 'Rule Base Number Format Rule Sets'
>
> Modified:
>      ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilNumber.java

Ew!  This is not directed at Hans, he just followed the existing
examples.  This stuff should not be hard-coded in java.  At the least,
some kind of external properties file(or xml).

ps: there's one real comment further down.

>
> Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilNumber.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilNumber.java?rev=1003459&r1=1003458&r2=1003459&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilNumber.java (original)
> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilNumber.java Fri Oct  1 09:56:20 2010
> @@ -152,11 +152,51 @@ public class UtilNumber {
>           + "%%hundredths:\n"
>           + "    100:<00<;\n";
>
> +    // ICU4J rule sets for the th_TH locale. To add more rules, expand this string.
> +    // For reference, see the RbnfSampleRuleSets.java file distributed with ICU4J
> +    public static final String ruleSet_th_TH =
> +        /*
> +         * These rules format a number in one of the two styles often used
> +         * on checks.  %bahts-and-hundredths formats stangs as hundredths of
> +         * a baht (23.40 comes out as "twenty-three and 40/100 bahts").
> +         * %bahts-and-stangs formats in bahts and stangs (23.40 comes out as
> +         * "twenty-three bahts and forty stangs")
> +         */
> +        "%bahts-and-stangs:\n"
> +        + "    x.0:<<  [and>%%stangs>];\n"
> +        + "    0.x:>%%stangs>;\n"
> +        + "    0: zero bahts; one baht; =%%main= bahts;\n"
> +        + "%%main:\n"
> +        + "    zero; one; two; three; four; five; six; seven; eight; nine;\n"
> +        + "    ten; eleven; twelve; thirteen; fourteen; fifteen; sixteen;\n"
> +        + "        seventeen; eighteen; nineteen;\n"
> +        + "    20: twenty[->>];\n"
> +        + "    30: thirty[->>];\n"
> +        + "    40: forty[->>];\n"
> +        + "    50: fifty[->>];\n"
> +        + "    60: sixty[->>];\n"
> +        + "    70: seventy[->>];\n"
> +        + "    80: eighty[->>];\n"
> +        + "    90: ninety[->>];\n"
> +        + "    100:<<  hundred[>>];\n"
> +        + "    1000:<<  thousand[>>];\n"
> +        + "    1,000,000:<<  million[>>];\n"
> +        + "    1,000,000,000:<<  billion[>>];\n"
> +        + "    1,000,000,000,000:<<  trillion[>>];\n"
> +        + "    1,000,000,000,000,000: =#,##0=;\n"
> +        + "%%stangs:\n"
> +        + "    100:<%%main<  stang[s];\n"
> +        + "%bahts-and-hundredths:\n"
> +        + "    x.0:<%%main<  and>%%hundredths>/100;\n" // this used to end in 'bahts' but that should be added later
> +        + "%%hundredths:\n"
> +        + "    100:<00<;\n";
> +
>       // hash map to store ICU4J rule sets keyed to Locale
>       public static HashMap<Locale, String>  rbnfRuleSets;
>       static {
>           rbnfRuleSets = new HashMap<Locale, String>();
>           rbnfRuleSets.put(Locale.US, ruleSet_en_US);
> +        rbnfRuleSets.put(new Locale("th"), ruleSet_th_TH);

Embedded tab, please be careful.


>       }
>
>       /**
>
>