1 /*---------------------------------------------------------------------------* 2 * ESR_Locale.c * 3 * * 4 * Copyright 2007, 2008 Nuance Communciations, Inc. * 5 * * 6 * Licensed under the Apache License, Version 2.0 (the 'License'); * 7 * you may not use this file except in compliance with the License. * 8 * * 9 * You may obtain a copy of the License at * 10 * http://www.apache.org/licenses/LICENSE-2.0 * 11 * * 12 * Unless required by applicable law or agreed to in writing, software * 13 * distributed under the License is distributed on an 'AS IS' BASIS, * 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 15 * See the License for the specific language governing permissions and * 16 * limitations under the License. * 17 * * 18 *---------------------------------------------------------------------------*/ 19 20 21 #include "ESR_Locale.h" 22 #include "plog.h" 23 #include "LCHAR.h" 24 25 26 LCHAR* ESR_locale2str(const ESR_Locale locale) 27 { 28 switch (locale) { 29 case ESR_LOCALE_EN_US: return L("ESR_LOCALE_EN_US"); 30 case ESR_LOCALE_FR_FR: return L("ESR_LOCALE_FR_FR"); 31 case ESR_LOCALE_DE_DE: return L("ESR_LOCALE_DE_DE"); 32 case ESR_LOCALE_EN_GB: return L("ESR_LOCALE_EN_GB"); 33 case ESR_LOCALE_IT_IT: return L("ESR_LOCALE_IT_IT"); 34 case ESR_LOCALE_NL_NL: return L("ESR_LOCALE_NL_NL"); 35 case ESR_LOCALE_PT_PT: return L("ESR_LOCALE_PT_PT"); 36 case ESR_LOCALE_ES_ES: return L("ESR_LOCALE_ES_ES"); 37 case ESR_LOCALE_JA_JP: return L("ESR_LOCALE_JA_JP"); 38 } 39 return L("invalid locale code"); 40 } 41 42 43 ESR_ReturnCode ESR_str2locale(const LCHAR* str, ESR_Locale* locale) 44 { 45 int rtn = 0; 46 if (!lstrcasecmp(str, L("EN-US"), &rtn) && !rtn) *locale = ESR_LOCALE_EN_US; 47 else if (!lstrcasecmp(str, L("FR-FR"), &rtn) && !rtn) *locale = ESR_LOCALE_FR_FR; 48 else if (!lstrcasecmp(str, L("DE-DE"), &rtn) && !rtn) *locale = ESR_LOCALE_DE_DE; 49 else if (!lstrcasecmp(str, L("EN-GB"), &rtn) && !rtn) *locale = ESR_LOCALE_EN_GB; 50 else if (!lstrcasecmp(str, L("IT-IT"), &rtn) && !rtn) *locale = ESR_LOCALE_IT_IT; 51 else if (!lstrcasecmp(str, L("NL-NL"), &rtn) && !rtn) *locale = ESR_LOCALE_NL_NL; 52 else if (!lstrcasecmp(str, L("PT-PT"), &rtn) && !rtn) *locale = ESR_LOCALE_PT_PT; 53 else if (!lstrcasecmp(str, L("ES-ES"), &rtn) && !rtn) *locale = ESR_LOCALE_ES_ES; 54 else if (!lstrcasecmp(str, L("JA-JP"), &rtn) && !rtn) *locale = ESR_LOCALE_JA_JP; 55 else { 56 PLogError(L("no locale defined for %s"), str); 57 return ESR_INVALID_ARGUMENT; 58 } 59 return ESR_SUCCESS; 60 } 61