diff --git a/tools/NLS/Xlat/Xlat.cpp b/tools/NLS/Xlat/Xlat.cpp index 26583889f9e98b30dfacdf79d2c6f9b7e7ac6ae7..1076185c6f5eeee36119aff7ff8a626f08faff47 100644 --- a/tools/NLS/Xlat/Xlat.cpp +++ b/tools/NLS/Xlat/Xlat.cpp @@ -57,6 +57,9 @@ /* * $Log$ + * Revision 1.16 2002/12/12 23:40:39 peiyongz + * normlize locale string. + * * Revision 1.15 2002/11/12 17:24:58 tng * DOM Message: add new domain for DOM Messages. * @@ -502,11 +505,33 @@ extern "C" int wmain(int argC, XMLCh** argV) // const unsigned int count = msgSetList->getLength(); + // + // Normalize locale string + // + // locale = ll[[_CC][_VARIANT]] + // where ll is language code + // CC is country code + // VARIANT is variant code + // + XMLCh normalizedLocale[256]; + + normalizedLocale[0] = localeStr[0]; + normalizedLocale[1] = localeStr[1]; + normalizedLocale[2] = 0; + XMLString::lowerCase(normalizedLocale); + + if (XMLString::stringLen(localeStr) > 2) + { + XMLString::catString(&(normalizedLocale[2]), &(localeStr[2])); + XMLString::upperCase(&(normalizedLocale[2])); + } + // // Ok, its good enough to get started. So lets call the start output // method on the formatter. // - formatter->startOutput(localeStr, gOutPath); + + formatter->startOutput(normalizedLocale, gOutPath); // // For each message domain element, we call start and end domain diff --git a/tools/NLS/Xlat/Xlat_ICUResourceBundle.cpp b/tools/NLS/Xlat/Xlat_ICUResourceBundle.cpp index 847e0f34fcad001de9bf5e9ea369f70c261e37cb..8b589267280fbdc520c00cb5747b126e675474fa 100644 --- a/tools/NLS/Xlat/Xlat_ICUResourceBundle.cpp +++ b/tools/NLS/Xlat/Xlat_ICUResourceBundle.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.3 2002/12/12 23:40:38 peiyongz + * normlize locale string. + * * Revision 1.2 2002/11/05 21:15:16 peiyongz * generate correct <locale>.txt file * @@ -210,28 +213,9 @@ void ICUResBundFormatter::startOutput(const XMLCh* const locale const unsigned int bufSize = 4095; XMLCh tmpBuf[bufSize + 1]; - // - // we got to comform to locale specs - // that is en_US - // - XMLCh tempLocale[bufSize+1]; - XMLCh tempLan[64]; - int lang_end = XMLString::indexOf(locale, chUnderscore); - if (lang_end != -1) - { - XMLString::subString(tempLan, locale, 0, lang_end); - tempLan[lang_end] = 0; - XMLString::lowerCase(tempLan); - XMLString::copyString(tempLocale, tempLan); - tempLocale[lang_end] = 0; - XMLString::catString(&(tempLocale[lang_end]), &(locale[lang_end])); - } - else - { - XMLString::copyString(tempLocale, locale); - } - swprintf(tmpBuf, L"%s/%s.txt", outPath, tempLocale); + + swprintf(tmpBuf, L"%s/%s.txt", outPath, locale); fOutFl = _wfopen(tmpBuf, L"wt"); if (!fOutFl) { @@ -240,6 +224,6 @@ void ICUResBundFormatter::startOutput(const XMLCh* const locale } // Set the message delimiter - fwprintf(fOutFl, L"%s { \n", tempLocale); + fwprintf(fOutFl, L"%s { \n", locale); }