Community articleLocalizationManager_SetCurrentThreadStringValue function
Added by IBM contributorIBM on May 2, 2012
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars




Description

This function has a dual purpose. It can set the language that the API uses when reporting errors, and it can set the time zone that the API uses in all of its date and time operations.
The function takes two string parameters. The first parameter is a key and the second is a value. The key "Locale" sets the language, and the key "TimeZoneId" sets the time zone. The supported languages are listed in Table 1. The supported time zones are the time zones in the International Components for Unicode (ICU) library, which correspond to Olson time zone data.

Function

   r_error LocalizationManager_SetCurrentThreadStringValue(
      r_charP key, 
      r_charP value
   );


Parameters

Table 1. set current thread string value parameters
ExpressionTypeDescription
key r_charPMust be "Locale" to set the language that the API uses for error reporting, or "TimeZoneId" to set the time zone that the API uses in all of its date and time operations.
valuer_charPWhen setting the language, use any one of the Locale Names that correspond to the language that you want. The valid Locale Names are listed in Table 1.
When setting the time zone, use a valid time zone ID from the ICU library or from the Olson time zone database. The ID is of the form continent/city or ocean/city. For example, the ID "America/Los_Angeles" will set the time zone to the west coast of USA.


Returns

OK on success or an error code on failure. If you pass in a non valid Locale Name, the function will not return an error code. An error code is returned only if the function fails to set a value.

Notes

The API can report errors in the following languages:
Table 2. API supported languages
LanguageLocaleLocale Name
ArabicAlgeriaar_DZ

Bahrain ar_BH

Egyptar_EG

Iraqar_IQ

Jordanar_JO

Kuwaitar_KW

Lebanonar_LB

Libyaar_LY

Moroccoar_MA

Omanar_OM

Qatarar_QA

Saudi Arabiaar_SA

Sudanar_SD

Syriaar_SY

Tunisiaar_TN

United Arab Emiratesar_AE

Yemenar_YE
ChineseSimplified Han, Chinazh_Hans_CN

Simplified Han, Singaporezh_Hans_SG

Traditional Han, Hong Kong S.A.R., Chinazh_Hant_HK

Traditional Han, Taiwanzh_Hant_TW
CroatianCroatiahr_HT
CzechCzech Republiccs_CZ
DanishDenmarkda_DK
DutchBelgiumnl_BE

The Netherlandsnl_NL
EnglishAustraliaen_AU

Belgiumen_BE

Canadaen_CA

Hong Kong S.A.R., Chinaen_HK

Indiaen_IN

Irelanden_IE

New Zealanden_NZ

Philippinesen_PH

Singaporeen_SG

South Africaen_ZA

United Kingdomen_GB

United Statesen_US
FinnishFinlandfi_FI
FrenchBelgiumfr_BE

Canadafr_CA

Francefr_FR

Luxembourgfr_LU

Switzerlandfr_CH
GermanAustriade_AT

Germanyde_DE

Luxembourgde_LU

Switzerlandde_CH
GreekGreeceel_GR
HebrewIsraelhe_IL
HungarianHungaryhu_HU
ItalianItalyit_IT

Switzerlandit_CH
JapaneseJapanja_JP
KoreanSouth Koreako_KR
Norwegian BokmålNorwaynb_NO
PolishPolandpl_PL
PortugueseBrazilpt_BR

Portugalpt_PT
RomanianRomaniaro_RO
RussianRussianru_RU
SlovakSlovakiask_SK
SloveneSloveniasl_SI
SpanishArgentinaes_AR

Boliviaes_BO

Chilees_CL

Colombiaes_CO

Costa Ricaes_CR

Dominican Republices_DO

Ecuadores_EC

El Salvadores_SV

Guatemalaes_GT

Hondurases_HN

Mexicoes_MX

Nicaraguaes_NI

Panamaes_PA

Paraguayes_PY

Perues_PE

Puerto Ricoes_PR

Spaines_ES

United Stateses_US

Uruguayes_UY

Venezuelaes_VE
SwedishSwedensv_SE
TurkishTurkeytr_TR


Example

When called with the string "Paris", the sample function sets the language to French and the time zone to Europe/Paris.
r_error setCurrentLocation(r_charP location)
{
  r_error error;
 
  if (cp_strcmp(location, "Paris") == OK)
  {
    if ((error = LocalizationManager_SetCurrentThreadStringValue("Locale", "fr_FR")) != OK)
    {
      fprintf(stderr, "LocalizationManager_SetCurrentThreadStringValue Locale error %d./n", error);
      return(NOTOK);
    }
    if ((error = LocalizationManager_SetCurrentThreadStringValue("TimeZoneId", "Europe/Paris")) != OK)
    {
      fprintf(stderr, "LocalizationManager_SetCurrentThreadStringValue TimeZoneId error %d./n", error);
      return(NOTOK);
    }
  }
}