Main Page | Data Structures | Directories | File List | Data Fields | Globals

localename.c File Reference

#include <stdlib.h>
#include <locale.h>

Go to the source code of this file.

Functions

const char * _nl_locale_name (int category, const char *categoryname)


Function Documentation

const char* _nl_locale_name int  category,
const char *  categoryname
 

Definition at line 384 of file localename.c.

00387 {
00388   const char *retval;
00389 
00390 #ifndef WIN32
00391 
00392   /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
00393      On some systems this can be done by the 'setlocale' function itself.  */
00394 # if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
00395   retval = setlocale (category, NULL);
00396 # else
00397   /* Setting of LC_ALL overwrites all other.  */
00398   retval = getenv ("LC_ALL");
00399   if (retval == NULL || retval[0] == '\0')
00400     {
00401       /* Next comes the name of the desired category.  */
00402       retval = getenv (categoryname);
00403       if (retval == NULL || retval[0] == '\0')
00404         {
00405           /* Last possibility is the LANG environment variable.  */
00406           retval = getenv ("LANG");
00407           if (retval == NULL || retval[0] == '\0')
00408             /* We use C as the default domain.  POSIX says this is
00409                implementation defined.  */
00410             retval = "C";
00411         }
00412     }
00413 # endif
00414 
00415   return retval;
00416 
00417 #else /* WIN32 */
00418 
00419   /* Return an XPG style locale name language[_territory][@modifier].
00420      Don't even bother determining the codeset; it's not useful in this
00421      context, because message catalogs are not specific to a single
00422      codeset.  */
00423 
00424   LCID lcid;
00425   LANGID langid;
00426   int primary, sub;
00427 
00428   /* Let the user override the system settings through environment
00429      variables, as on POSIX systems.  */
00430   retval = getenv ("LC_ALL");
00431   if (retval != NULL && retval[0] != '\0')
00432     return retval;
00433   retval = getenv (categoryname);
00434   if (retval != NULL && retval[0] != '\0')
00435     return retval;
00436   retval = getenv ("LANG");
00437   if (retval != NULL && retval[0] != '\0')
00438     return retval;
00439 
00440   /* Use native Win32 API locale ID.  */
00441   lcid = GetThreadLocale ();
00442 
00443   /* Strip off the sorting rules, keep only the language part.  */
00444   langid = LANGIDFROMLCID (lcid);
00445 
00446   /* Split into language and territory part.  */
00447   primary = PRIMARYLANGID (langid);
00448   sub = SUBLANGID (langid);
00449 
00450   /* Dispatch on language.
00451      See also http://www.unicode.org/unicode/onlinedat/languages.html .
00452      For details about languages, see http://www.ethnologue.com/ .  */
00453   switch (primary)
00454     {
00455     case LANG_AFRIKAANS: return "af_ZA";
00456     case LANG_ALBANIAN: return "sq_AL";
00457     case 0x5e: /* AMHARIC */ return "am_ET";
00458     case LANG_ARABIC:
00459       switch (sub)
00460         {
00461         case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA";
00462         case SUBLANG_ARABIC_IRAQ: return "ar_IQ";
00463         case SUBLANG_ARABIC_EGYPT: return "ar_EG";
00464         case SUBLANG_ARABIC_LIBYA: return "ar_LY";
00465         case SUBLANG_ARABIC_ALGERIA: return "ar_DZ";
00466         case SUBLANG_ARABIC_MOROCCO: return "ar_MA";
00467         case SUBLANG_ARABIC_TUNISIA: return "ar_TN";
00468         case SUBLANG_ARABIC_OMAN: return "ar_OM";
00469         case SUBLANG_ARABIC_YEMEN: return "ar_YE";
00470         case SUBLANG_ARABIC_SYRIA: return "ar_SY";
00471         case SUBLANG_ARABIC_JORDAN: return "ar_JO";
00472         case SUBLANG_ARABIC_LEBANON: return "ar_LB";
00473         case SUBLANG_ARABIC_KUWAIT: return "ar_KW";
00474         case SUBLANG_ARABIC_UAE: return "ar_AE";
00475         case SUBLANG_ARABIC_BAHRAIN: return "ar_BH";
00476         case SUBLANG_ARABIC_QATAR: return "ar_QA";
00477         }
00478       return "ar";
00479     case LANG_ARMENIAN: return "hy_AM";
00480     case LANG_ASSAMESE: return "as_IN";
00481     case LANG_AZERI:
00482       switch (sub)
00483         {
00484         /* FIXME: Adjust this when Azerbaijani locales appear on Unix.  */
00485         case SUBLANG_AZERI_LATIN: return "az_AZ@latin";
00486         case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic";
00487         }
00488       return "az";
00489     case LANG_BASQUE:
00490       return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR".  */
00491     case LANG_BELARUSIAN: return "be_BY";
00492     case LANG_BENGALI: return "bn_IN";
00493     case LANG_BULGARIAN: return "bg_BG";
00494     case 0x55: /* BURMESE */ return "my_MM";
00495     case 0x53: /* CAMBODIAN */ return "km_KH";
00496     case LANG_CATALAN: return "ca_ES";
00497     case 0x5c: /* CHEROKEE */ return "chr_US";
00498     case LANG_CHINESE:
00499       switch (sub)
00500         {
00501         case SUBLANG_CHINESE_TRADITIONAL: return "zh_TW";
00502         case SUBLANG_CHINESE_SIMPLIFIED: return "zh_CN";
00503         case SUBLANG_CHINESE_HONGKONG: return "zh_HK";
00504         case SUBLANG_CHINESE_SINGAPORE: return "zh_SG";
00505         case SUBLANG_CHINESE_MACAU: return "zh_MO";
00506         }
00507       return "zh";
00508     case LANG_CROATIAN:         /* LANG_CROATIAN == LANG_SERBIAN
00509                                  * What used to be called Serbo-Croatian
00510                                  * should really now be two separate
00511                                  * languages because of political reasons.
00512                                  * (Says tml, who knows nothing about Serbian
00513                                  * or Croatian.)
00514                                  * (I can feel those flames coming already.)
00515                                  */
00516       switch (sub)
00517         {
00518         case SUBLANG_DEFAULT: return "hr_HR";
00519         case SUBLANG_SERBIAN_LATIN: return "sr_YU";
00520         case SUBLANG_SERBIAN_CYRILLIC: return "sr_YU@cyrillic";
00521         }
00522       return "hr";
00523     case LANG_CZECH: return "cs_CZ";
00524     case LANG_DANISH: return "da_DK";
00525     case LANG_DIVEHI: return "div_MV";
00526     case LANG_DUTCH:
00527       switch (sub)
00528         {
00529         case SUBLANG_DUTCH: return "nl_NL";
00530         case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE";
00531         }
00532       return "nl";
00533     case 0x66: /* EDO */ return "bin_NG";
00534     case LANG_ENGLISH:
00535       switch (sub)
00536         {
00537         /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
00538          * English was the language spoken in England.
00539          * Oh well.
00540          */
00541         case SUBLANG_ENGLISH_US: return "en_US";
00542         case SUBLANG_ENGLISH_UK: return "en_GB";
00543         case SUBLANG_ENGLISH_AUS: return "en_AU";
00544         case SUBLANG_ENGLISH_CAN: return "en_CA";
00545         case SUBLANG_ENGLISH_NZ: return "en_NZ";
00546         case SUBLANG_ENGLISH_EIRE: return "en_IE";
00547         case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA";
00548         case SUBLANG_ENGLISH_JAMAICA: return "en_JM";
00549         case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */
00550         case SUBLANG_ENGLISH_BELIZE: return "en_BZ";
00551         case SUBLANG_ENGLISH_TRINIDAD: return "en_TT";
00552         case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW";
00553         case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH";
00554         }
00555       return "en";
00556     case LANG_ESTONIAN: return "et_EE";
00557     case LANG_FAEROESE: return "fo_FO";
00558     case LANG_FARSI: return "fa_IR";
00559     case LANG_FINNISH: return "fi_FI";
00560     case LANG_FRENCH:
00561       switch (sub)
00562         {
00563         case SUBLANG_FRENCH: return "fr_FR";
00564         case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE";
00565         case SUBLANG_FRENCH_CANADIAN: return "fr_CA";
00566         case SUBLANG_FRENCH_SWISS: return "fr_CH";
00567         case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU";
00568         case SUBLANG_FRENCH_MONACO: return "fr_MC";
00569         }
00570       return "fr";
00571     case 0x62: /* FRISIAN */ return "fy_NL";
00572     case 0x67: /* FULFULDE */ return "ful_NG";
00573     case 0x3c: /* GAELIC */
00574       switch (sub)
00575         {
00576         case 0x01: /* SCOTTISH */ return "gd_GB";
00577         case 0x02: /* IRISH */ return "ga_IE";
00578         }
00579       return "C";
00580     case LANG_GALICIAN: return "gl_ES";
00581     case LANG_GEORGIAN: return "ka_GE";
00582     case LANG_GERMAN:
00583       switch (sub)
00584         {
00585         case SUBLANG_GERMAN: return "de_DE";
00586         case SUBLANG_GERMAN_SWISS: return "de_CH";
00587         case SUBLANG_GERMAN_AUSTRIAN: return "de_AT";
00588         case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU";
00589         case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI";
00590         }
00591       return "de";
00592     case LANG_GREEK: return "el_GR";
00593     case 0x74: /* GUARANI */ return "gn_PY";
00594     case LANG_GUJARATI: return "gu_IN";
00595     case 0x68: /* HAUSA */ return "ha_NG";
00596     case 0x75: /* HAWAIIAN */
00597       /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers)
00598          or Hawaii Creole English ("cpe_US", 600000 speakers)?  */
00599       return "cpe_US";
00600     case LANG_HEBREW: return "he_IL";
00601     case LANG_HINDI: return "hi_IN";
00602     case LANG_HUNGARIAN: return "hu_HU";
00603     case 0x69: /* IBIBIO */ return "nic_NG";
00604     case LANG_ICELANDIC: return "is_IS";
00605     case 0x70: /* IGBO */ return "ibo_NG";
00606     case LANG_INDONESIAN: return "id_ID";
00607     case 0x5d: /* INUKTITUT */ return "iu_CA";
00608     case LANG_ITALIAN:
00609       switch (sub)
00610         {
00611         case SUBLANG_ITALIAN: return "it_IT";
00612         case SUBLANG_ITALIAN_SWISS: return "it_CH";
00613         }
00614       return "it";
00615     case LANG_JAPANESE: return "ja_JP";
00616     case LANG_KANNADA: return "kn_IN";
00617     case 0x71: /* KANURI */ return "kau_NG";
00618     case LANG_KASHMIRI:
00619       switch (sub)
00620         {
00621         case SUBLANG_DEFAULT: return "ks_PK";
00622         case SUBLANG_KASHMIRI_INDIA: return "ks_IN";
00623         }
00624       return "ks";
00625     case LANG_KAZAK: return "kk_KZ";
00626     case LANG_KONKANI:
00627       /* FIXME: Adjust this when such locales appear on Unix.  */
00628       return "kok_IN";
00629     case LANG_KOREAN: return "ko_KR";
00630     case LANG_KYRGYZ: return "ky_KG";
00631     case 0x54: /* LAO */ return "lo_LA";
00632     case 0x76: /* LATIN */ return "la_VA";
00633     case LANG_LATVIAN: return "lv_LV";
00634     case LANG_LITHUANIAN: return "lt_LT";
00635     case LANG_MACEDONIAN: return "mk_MK";
00636     case LANG_MALAY:
00637       switch (sub)
00638         {
00639         case SUBLANG_MALAY_MALAYSIA: return "ms_MY";
00640         case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN";
00641         }
00642       return "ms";
00643     case LANG_MALAYALAM: return "ml_IN";
00644     case 0x3a: /* MALTESE */ return "mt_MT";
00645     case LANG_MANIPURI:
00646       /* FIXME: Adjust this when such locales appear on Unix.  */
00647       return "mni_IN";
00648     case LANG_MARATHI: return "mr_IN";
00649     case LANG_MONGOLIAN:
00650       return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN".  */
00651     case LANG_NEPALI:
00652       switch (sub)
00653         {
00654         case SUBLANG_DEFAULT: return "ne_NP";
00655         case SUBLANG_NEPALI_INDIA: return "ne_IN";
00656         }
00657       return "ne";
00658     case LANG_NORWEGIAN:
00659       switch (sub)
00660         {
00661         case SUBLANG_NORWEGIAN_BOKMAL: return "no_NO";
00662         case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO";
00663         }
00664       return "no";
00665     case LANG_ORIYA: return "or_IN";
00666     case 0x72: /* OROMO */ return "om_ET";
00667     case 0x79: /* PAPIAMENTU */ return "pap_AN";
00668     case 0x63: /* PASHTO */
00669       return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF".  */
00670     case LANG_POLISH: return "pl_PL";
00671     case LANG_PORTUGUESE:
00672       switch (sub)
00673         {
00674         case SUBLANG_PORTUGUESE: return "pt_PT";
00675         /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
00676            Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
00677         case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR";
00678         }
00679       return "pt";
00680     case LANG_PUNJABI: return "pa_IN";
00681     case 0x17: /* RHAETO-ROMANCE */ return "rm_CH";
00682     case LANG_ROMANIAN: return "ro_RO";
00683     case LANG_RUSSIAN:
00684       return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA".  */
00685     case 0x3b: /* SAMI */ return "se_NO";
00686     case LANG_SANSKRIT: return "sa_IN";
00687     case LANG_SINDHI: return "sd";
00688     case 0x5b: /* SINHALESE */ return "si_LK";
00689     case LANG_SLOVAK: return "sk_SK";
00690     case LANG_SLOVENIAN: return "sl_SI";
00691     case 0x77: /* SOMALI */ return "so_SO";
00692     case LANG_SORBIAN:
00693       /* FIXME: Adjust this when such locales appear on Unix.  */
00694       return "wen_DE";
00695     case LANG_SPANISH:
00696       switch (sub)
00697         {
00698         case SUBLANG_SPANISH: return "es_ES";
00699         case SUBLANG_SPANISH_MEXICAN: return "es_MX";
00700         case SUBLANG_SPANISH_MODERN:
00701           return "es_ES@modern";        /* not seen on Unix */
00702         case SUBLANG_SPANISH_GUATEMALA: return "es_GT";
00703         case SUBLANG_SPANISH_COSTA_RICA: return "es_CR";
00704         case SUBLANG_SPANISH_PANAMA: return "es_PA";
00705         case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO";
00706         case SUBLANG_SPANISH_VENEZUELA: return "es_VE";
00707         case SUBLANG_SPANISH_COLOMBIA: return "es_CO";
00708         case SUBLANG_SPANISH_PERU: return "es_PE";
00709         case SUBLANG_SPANISH_ARGENTINA: return "es_AR";
00710         case SUBLANG_SPANISH_ECUADOR: return "es_EC";
00711         case SUBLANG_SPANISH_CHILE: return "es_CL";
00712         case SUBLANG_SPANISH_URUGUAY: return "es_UY";
00713         case SUBLANG_SPANISH_PARAGUAY: return "es_PY";
00714         case SUBLANG_SPANISH_BOLIVIA: return "es_BO";
00715         case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV";
00716         case SUBLANG_SPANISH_HONDURAS: return "es_HN";
00717         case SUBLANG_SPANISH_NICARAGUA: return "es_NI";
00718         case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR";
00719         }
00720       return "es";
00721     case 0x30: /* SUTU */ return "bnt_TZ";
00722     case LANG_SWAHILI: return "sw_KE";
00723     case LANG_SWEDISH:
00724       switch (sub)
00725         {
00726         case SUBLANG_DEFAULT: return "sv_SE";
00727         case SUBLANG_SWEDISH_FINLAND: return "sv_FI";
00728         }
00729       return "sv";
00730     case LANG_SYRIAC: return "syr_TR"; /* An extinct language.  */
00731     case 0x64: /* TAGALOG */ return "tl_PH";
00732     case 0x28: /* TAJIK */ return "tg_TJ";
00733     case 0x5f: /* TAMAZIGHT */ return "ber_MA";
00734     case LANG_TAMIL:
00735       return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG".  */
00736     case LANG_TATAR: return "tt_RU";
00737     case LANG_TELUGU: return "te_IN";
00738     case LANG_THAI: return "th_TH";
00739     case 0x51: /* TIBETAN */ return "bo_CN";
00740     case 0x73: /* TIGRINYA */ return "ti_ET";
00741     case 0x31: /* TSONGA */ return "ts_ZA";
00742     case LANG_TURKISH: return "tr_TR";
00743     case 0x42: /* TURKMEN */ return "tk_TM";
00744     case LANG_UKRAINIAN: return "uk_UA";
00745     case LANG_URDU:
00746       switch (sub)
00747         {
00748         case SUBLANG_URDU_PAKISTAN: return "ur_PK";
00749         case SUBLANG_URDU_INDIA: return "ur_IN";
00750         }
00751       return "ur";
00752     case LANG_UZBEK:
00753       switch (sub)
00754         {
00755         /* FIXME: Adjust this when Uzbek locales appear on Unix.  */
00756         case SUBLANG_UZBEK_LATIN: return "uz_UZ@latin";
00757         case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic";
00758         }
00759       return "uz";
00760     case 0x33: /* VENDA */ return "ven_ZA";
00761     case LANG_VIETNAMESE: return "vi_VN";
00762     case 0x52: /* WELSH */ return "cy_GB";
00763     case 0x34: /* XHOSA */ return "xh_ZA";
00764     case 0x78: /* YI */ return "sit_CN";
00765     case 0x3d: /* YIDDISH */ return "yi_IL";
00766     case 0x6a: /* YORUBA */ return "yo_NG";
00767     case 0x35: /* ZULU */ return "zu_ZA";
00768     default: return "C";
00769     }
00770 
00771 #endif
00772 }


Generated on Sun Dec 26 11:23:29 2004 for lincity by  doxygen 1.3.9.1