From d96218b396f31c00f2870c5eb586b32b00d7ca16 Mon Sep 17 00:00:00 2001 From: PeiYong Zhang <peiyongz@apache.org> Date: Thu, 12 Dec 2002 23:40:39 +0000 Subject: [PATCH] normlize locale string. git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174520 13f79535-47bb-0310-9956-ffa450edef68 --- tools/NLS/Xlat/Xlat.cpp | 27 +++++++++++++++++++++- tools/NLS/Xlat/Xlat_ICUResourceBundle.cpp | 28 +++++------------------ 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/tools/NLS/Xlat/Xlat.cpp b/tools/NLS/Xlat/Xlat.cpp index 26583889f..1076185c6 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 847e0f34f..8b5892672 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); } -- GitLab