><cfset finalString = formatter.format(javacast("long",
>inNumber),"%default")>

more for the i18n folks (everyone else avert your eyes ;-): after poking around 
a bit i can see that the format() method works w/out a wrapper if you pass in 
the ruleset name. cool, i've been out-researched ;-) but many locales have more 
than one ruleset, "%default" (one thousand and one) & "%simplified" (one 
thousand one). there are also many where the "default" ruleset isn't named 
"%default" but rather "%main" (italian, farsi, french) or in the case of german 
locales "%alt-ones" and in japan you have "%traditional" (一千一) and 
"%financial" (壱千壱). if i swap to pure cf, then the user will need to know 
which ruleset goes w/which locale (which is a bit contrary to what i think are 
good i18n practices). since icu4j is based on the cldr (common locale data 
repository) project it's likely the rulesets/locales will change over time so 
can't really hardcode these in the function. i guess the java wrapper is still 
the safest approach:

import com.ibm.icu.util.ULocale;
import java.lang.Double;
import com.ibm.icu.text.RuleBasedNumberFormat;

public class ruleBasedFormatter {

public final static String rbFormat(String thisLocale, Double thisNumber, int 
thisFormat) {
        /* thisFormat:
        3=duration (time)
        2=ordinal (2nd, 3rd, etc.),
        1=spellout (one hundred and one)
        */ 
        ULocale locale = new ULocale(thisLocale);
        RuleBasedNumberFormat spelloutFormatter = new 
RuleBasedNumberFormat(locale, thisFormat);
        String spelledOut = spelloutFormatter.format(thisNumber);
        return spelledOut;
}
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:224469
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to