ICU-1734 number spellout for fr_BE

X-SVN-Rev: 11622
This commit is contained in:
Doug Felt 2003-04-22 23:55:03 +00:00
parent b69c8dcb62
commit 42475ef053
5 changed files with 65 additions and 34 deletions

View file

@ -54,4 +54,8 @@ fr_BE {
"#,##0%",
"#E0",
}
// Reuse Swiss French spellout rules. Also for French in Zaire,
// but we've no locale for it yet.
SpelloutRules:alias { "/ICUDATA/fr_CH" }
}

View file

@ -86,7 +86,7 @@ fr_CH {
" 60: soixante[->%%alt-ones>];\n"
// notice new words for 70, 80, and 90
" 70: septante[->%%alt-ones>];\n"
" 80: octante[->%%alt-ones>];\n"
" 80: huitante[->%%alt-ones>];\n"
" 90: nonante[->%%alt-ones>];\n"
" 100: cent[ >>];\n"
" 200: << cents[ >>];\n"

View file

@ -80,14 +80,18 @@ RuleBasedNumberFormat::RuleBasedNumberFormat(URBNFRuleSetTag tag, const Locale&
default: status = U_ILLEGAL_ARGUMENT_ERROR; return;
}
UResourceBundle* nfrb = ures_open(NULL, locale.getName(), &status);
// the following doesn't work for aliased resources
// const UChar* description = ures_getStringByKey(nfrb, fmt_tag, &len, &status);
int32_t len = 0;
const UChar* description = ures_getStringByKey(nfrb, fmt_tag, &len, &status);
UResourceBundle* nfrb = ures_open(NULL, locale.getName(), &status);
UResourceBundle* yuck = ures_getByKey(nfrb, fmt_tag, NULL, &status);
const UChar* description = ures_getString(yuck, &len, &status);
if (U_SUCCESS(status)) {
UnicodeString desc(description, len);
UParseError perror;
init (desc, perror, status);
}
ures_close(yuck);
ures_close(nfrb);
}

View file

@ -55,6 +55,7 @@ void IntlTestRBNF::runIndexedTest(int32_t index, UBool exec, const char* &name,
TESTCASE(9, TestAPI);
TESTCASE(10, TestFractionalRuleSet);
TESTCASE(11, TestSwedishSpellout);
TESTCASE(12, TestBelgianFrenchSpellout);
#else
TESTCASE(0, TestRBNFDisabled);
#endif
@ -1152,6 +1153,36 @@ IntlTestRBNF::TestFrenchSpellout()
delete formatter;
}
static const char* swissFrenchTestData[][2] = {
{ "1", "un" },
{ "15", "quinze" },
{ "20", "vingt" },
{ "21", "vingt-et-un" },
{ "23", "vingt-trois" },
{ "62", "soixante-deux" },
{ "70", "septante" },
{ "71", "septante-et-un" },
{ "73", "septante-trois" },
{ "80", "huitante" },
{ "88", "huitante-huit" },
{ "100", "cent" },
{ "106", "cent six" },
{ "127", "cent vingt-sept" },
{ "200", "deux cents" },
{ "579", "cinq cents septante-neuf" },
{ "1,000", "mille" },
{ "1,123", "onze cents vingt-trois" },
{ "1,594", "mille cinq cents nonante-quatre" },
{ "2,000", "deux mille" },
{ "3,004", "trois mille quatre" },
{ "4,567", "quatre mille cinq cents soixante-sept" },
{ "15,943", "quinze mille neuf cents quarante-trois" },
{ "2,345,678", "deux million trois cents quarante-cinq mille six cents septante-huit" },
{ "-36", "moins trente-six" },
{ "234.567", "deux cents trente-quatre virgule cinq six sept" },
{ NULL, NULL}
};
void
IntlTestRBNF::TestSwissFrenchSpellout()
{
@ -1162,37 +1193,24 @@ IntlTestRBNF::TestSwissFrenchSpellout()
if (U_FAILURE(status)) {
errln("FAIL: could not construct formatter");
} else {
static const char* testData[][2] = {
{ "1", "un" },
{ "15", "quinze" },
{ "20", "vingt" },
{ "21", "vingt-et-un" },
{ "23", "vingt-trois" },
{ "62", "soixante-deux" },
{ "70", "septante" },
{ "71", "septante-et-un" },
{ "73", "septante-trois" },
{ "80", "octante" },
{ "88", "octante-huit" },
{ "100", "cent" },
{ "106", "cent six" },
{ "127", "cent vingt-sept" },
{ "200", "deux cents" },
{ "579", "cinq cents septante-neuf" },
{ "1,000", "mille" },
{ "1,123", "onze cents vingt-trois" },
{ "1,594", "mille cinq cents nonante-quatre" },
{ "2,000", "deux mille" },
{ "3,004", "trois mille quatre" },
{ "4,567", "quatre mille cinq cents soixante-sept" },
{ "15,943", "quinze mille neuf cents quarante-trois" },
{ "2,345,678", "deux million trois cents quarante-cinq mille six cents septante-huit" },
{ "-36", "moins trente-six" },
{ "234.567", "deux cents trente-quatre virgule cinq six sept" },
{ NULL, NULL}
};
doTest(formatter, testData, TRUE);
doTest(formatter, swissFrenchTestData, TRUE);
}
delete formatter;
}
void
IntlTestRBNF::TestBelgianFrenchSpellout()
{
UErrorCode status = U_ZERO_ERROR;
RuleBasedNumberFormat* formatter
= new RuleBasedNumberFormat(URBNF_SPELLOUT, Locale("fr", "BE", ""), status);
if (U_FAILURE(status)) {
fprintf(stderr, "rbnf status: %d (%x)\n", status, status);
errln("FAIL: could not construct formatter");
} else {
// Belgian french should match Swiss french.
doTest(formatter, swissFrenchTestData, TRUE);
}
delete formatter;
}

View file

@ -72,6 +72,11 @@ class IntlTestRBNF : public IntlTest {
*/
virtual void TestSwissFrenchSpellout();
/**
* Check that Belgian French matches Swiss French spellout rules
*/
virtual void TestBelgianFrenchSpellout();
/**
* Perform a simple spot check on the Italian spellout rules
*/