changeset 11304:a2786ccc7dbc

New module 'unicase/locale-language'.
author Bruno Haible <bruno@clisp.org>
date Sun, 08 Mar 2009 14:10:58 +0100
parents 1688f282d648
children 0483174037b1
files ChangeLog lib/unicase/locale-language.c lib/unicase/locale-languages.gperf modules/unicase/locale-language
diffstat 4 files changed, 364 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Mar 08 14:08:52 2009 +0100
+++ b/ChangeLog	Sun Mar 08 14:10:58 2009 +0100
@@ -1,5 +1,10 @@
 2009-03-08  Bruno Haible  <bruno@clisp.org>
 
+	New module 'unicase/locale-language'.
+	* lib/unicase/locale-language.c: New file.
+	* lib/unicase/locale-languages.gperf: New file.
+	* modules/unicase/locale-language: New file.
+
 	Generate more tables for case conversion and case folding.
 	* lib/gen-uni-tables.c (SCC_*): New enum items.
 	(struct special_casing_rule): New type.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/unicase/locale-language.c	Sun Mar 08 14:10:58 2009 +0100
@@ -0,0 +1,55 @@
+/* Language code of current locale.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2009.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published
+   by the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "unicase.h"
+
+#include <locale.h>
+#include <string.h>
+
+#include "localename.h"
+
+#include "unicase/locale-languages.h"
+
+const char *
+uc_locale_language (void)
+{
+  const char *locale_name = gl_locale_name (LC_CTYPE, "LC_CTYPE");
+  const char *p;
+
+  /* Find the end of the language portion.  */
+  p = locale_name;
+  while (*p != '\0' && *p != '_' && *p != '.' && *p != '@')
+    p++;
+
+  /* Return a statically allocated pointer to the language portion, so that the
+     caller of this function does not need to free() the result.
+     We could use a dynamically built unification table.  But given that the
+     set of possible languages is small, it is easier (and excludes ENOMEM
+     error conditions) to allocate the unification table statically.  */
+  if (p != locale_name)
+    {
+      const char *language =
+	uc_locale_languages_lookup (locale_name, p - locale_name);
+      if (language != NULL)
+	return language;
+    }
+
+  return "";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/unicase/locale-languages.gperf	Sun Mar 08 14:10:58 2009 +0100
@@ -0,0 +1,270 @@
+%language=ANSI-C
+%define hash-function-name uc_locale_language_hash
+%define lookup-function-name uc_locale_languages_lookup
+%compare-lengths
+%compare-strncmp
+%readonly-tables
+%pic
+/* List of languages taken from gettext/gettext-tools/src/lang-table.c
+   on 2009-02-07.  */
+%%
+"aa", /* Afar" */
+"ab", /* Abkhazian" */
+"ace", /* Achinese" */
+"ae", /* Avestan" */
+"af", /* Afrikaans" */
+"ak", /* Akan" */
+"am", /* Amharic" */
+"an", /* Aragonese" */
+"ang", /* Old English" */
+"ar", /* Arabic" */
+"as", /* Assamese" */
+"ast", /* Asturian" */
+"av", /* Avaric" */
+"awa", /* Awadhi" */
+"ay", /* Aymara" */
+"az", /* Azerbaijani" */
+"ba", /* Bashkir" */
+"bal", /* Baluchi" */
+"ban", /* Balinese" */
+"be", /* Belarusian" */
+"bej", /* Beja" */
+"bem", /* Bemba" */
+"bg", /* Bulgarian" */
+"bh", /* Bihari" */
+"bho", /* Bhojpuri" */
+"bi", /* Bislama" */
+"bik", /* Bikol" */
+"bin", /* Bini" */
+"bm", /* Bambara" */
+"bn", /* Bengali" */
+"bo", /* Tibetan" */
+"br", /* Breton" */
+"bs", /* Bosnian" */
+"bug", /* Buginese" */
+"ca", /* Catalan" */
+"ce", /* Chechen" */
+"ceb", /* Cebuano" */
+"ch", /* Chamorro" */
+"co", /* Corsican" */
+"cr", /* Cree" */
+"crh", /* Crimean Tatar" */
+"cs", /* Czech" */
+"csb", /* Kashubian" */
+"cu", /* Church Slavic" */
+"cv", /* Chuvash" */
+"cy", /* Welsh" */
+"da", /* Danish" */
+"de", /* German" */
+"din", /* Dinka" */
+"doi", /* Dogri" */
+"dv", /* Divehi" */
+"dz", /* Dzongkha" */
+"ee", /* Ewe" */
+"el", /* Greek" */
+"en", /* English" */
+"eo", /* Esperanto" */
+"es", /* Spanish" */
+"et", /* Estonian" */
+"eu", /* Basque" */
+"fa", /* Persian" */
+"ff", /* Fulah" */
+"fi", /* Finnish" */
+"fil", /* Filipino" */
+"fj", /* Fijian" */
+"fo", /* Faroese" */
+"fon", /* Fon" */
+"fr", /* French" */
+"fur", /* Friulian" */
+"fy", /* Western Frisian" */
+"ga", /* Irish" */
+"gd", /* Scottish Gaelic" */
+"gl", /* Galician" */
+"gn", /* Guarani" */
+"gon", /* Gondi" */
+"gsw", /* Swiss German" */
+"gu", /* Gujarati" */
+"gv", /* Manx" */
+"ha", /* Hausa" */
+"he", /* Hebrew" */
+"hi", /* Hindi" */
+"hil", /* Hiligaynon" */
+"hmn", /* Hmong" */
+"ho", /* Hiri Motu" */
+"hr", /* Croatian" */
+"ht", /* Haitian" */
+"hu", /* Hungarian" */
+"hy", /* Armenian" */
+"hz", /* Herero" */
+"ia", /* Interlingua" */
+"id", /* Indonesian" */
+"ie", /* Interlingue" */
+"ig", /* Igbo" */
+"ii", /* Sichuan Yi" */
+"ik", /* Inupiak" */
+"ilo", /* Iloko" */
+"is", /* Icelandic" */
+"it", /* Italian" */
+"iu", /* Inuktitut" */
+"ja", /* Japanese" */
+"jab", /* Hyam" */
+"jv", /* Javanese" */
+"ka", /* Georgian" */
+"kab", /* Kabyle" */
+"kaj", /* Jju" */
+"kam", /* Kamba" */
+"kbd", /* Kabardian" */
+"kcg", /* Tyap" */
+"kdm", /* Kagoma" */
+"kg", /* Kongo" */
+"ki", /* Kikuyu" */
+"kj", /* Kuanyama" */
+"kk", /* Kazakh" */
+"kl", /* Kalaallisut" */
+"km", /* Central Khmer" */
+"kmb", /* Kimbundu" */
+"kn", /* Kannada" */
+"ko", /* Korean" */
+"kr", /* Kanuri" */
+"kru", /* Kurukh" */
+"ks", /* Kashmiri" */
+"ku", /* Kurdish" */
+"kv", /* Komi" */
+"kw", /* Cornish" */
+"ky", /* Kirghiz" */
+"kok", /* Konkani" */
+"la", /* Latin" */
+"lb", /* Letzeburgesch" */
+"lg", /* Ganda" */
+"li", /* Limburgish" */
+"ln", /* Lingala" */
+"lo", /* Laotian" */
+"lt", /* Lithuanian" */
+"lu", /* Luba-Katanga" */
+"lua", /* Luba-Lulua" */
+"luo", /* Luo" */
+"lv", /* Latvian" */
+"mad", /* Madurese" */
+"mag", /* Magahi" */
+"mai", /* Maithili" */
+"mak", /* Makasar" */
+"man", /* Mandingo" */
+"men", /* Mende" */
+"mg", /* Malagasy" */
+"mh", /* Marshallese" */
+"mi", /* Maori" */
+"min", /* Minangkabau" */
+"mk", /* Macedonian" */
+"ml", /* Malayalam" */
+"mn", /* Mongolian" */
+"mni", /* Manipuri" */
+"mo", /* Moldavian" */
+"mos", /* Mossi" */
+"mr", /* Marathi" */
+"ms", /* Malay" */
+"mt", /* Maltese" */
+"mwr", /* Marwari" */
+"my", /* Burmese" */
+"myn", /* Mayan" */
+"na", /* Nauru" */
+"nap", /* Neapolitan" */
+"nah", /* Nahuatl" */
+"nb", /* Norwegian Bokmal" */
+"nd", /* North Ndebele" */
+"nds", /* Low Saxon" */
+"ne", /* Nepali" */
+"ng", /* Ndonga" */
+"nl", /* Dutch" */
+"nn", /* Norwegian Nynorsk" */
+"no", /* Norwegian" */
+"nr", /* South Ndebele" */
+"nso", /* Northern Sotho" */
+"nv", /* Navajo" */
+"ny", /* Nyanja" */
+"nym", /* Nyamwezi" */
+"nyn", /* Nyankole" */
+"oc", /* Occitan" */
+"oj", /* Ojibwa" */
+"om", /* (Afan) Oromo" */
+"or", /* Oriya" */
+"os", /* Ossetian" */
+"pa", /* Punjabi" */
+"pag", /* Pangasinan" */
+"pam", /* Pampanga" */
+"pap", /* Papiamento" */
+"pbb", /* Páez" */
+"pi", /* Pali" */
+"pl", /* Polish" */
+"ps", /* Pashto" */
+"pt", /* Portuguese" */
+"qu", /* Quechua" */
+"raj", /* Rajasthani" */
+"rm", /* Romansh" */
+"rn", /* Kirundi" */
+"ro", /* Romanian" */
+"ru", /* Russian" */
+"rw", /* Kinyarwanda" */
+"sa", /* Sanskrit" */
+"sas", /* Sasak" */
+"sat", /* Santali" */
+"sc", /* Sardinian" */
+"scn", /* Sicilian" */
+"sd", /* Sindhi" */
+"se", /* Northern Sami" */
+"sg", /* Sango" */
+"shn", /* Shan" */
+"si", /* Sinhala" */
+"sid", /* Sidamo" */
+"sk", /* Slovak" */
+"sl", /* Slovenian" */
+"sm", /* Samoan" */
+"sn", /* Shona" */
+"so", /* Somali" */
+"sq", /* Albanian" */
+"sr", /* Serbian" */
+"srr", /* Serer" */
+"ss", /* Siswati" */
+"st", /* Sesotho" */
+"su", /* Sundanese" */
+"suk", /* Sukuma" */
+"sus", /* Susu" */
+"sv", /* Swedish" */
+"sw", /* Swahili" */
+"ta", /* Tamil" */
+"te", /* Telugu" */
+"tem", /* Timne" */
+"tet", /* Tetum" */
+"tg", /* Tajik" */
+"th", /* Thai" */
+"ti", /* Tigrinya" */
+"tiv", /* Tiv" */
+"tk", /* Turkmen" */
+"tl", /* Tagalog" */
+"tn", /* Setswana" */
+"to", /* Tonga" */
+"tr", /* Turkish" */
+"ts", /* Tsonga" */
+"tt", /* Tatar" */
+"tum", /* Tumbuka" */
+"tw", /* Twi" */
+"ty", /* Tahitian" */
+"ug", /* Uighur" */
+"uk", /* Ukrainian" */
+"umb", /* Umbundu" */
+"ur", /* Urdu" */
+"uz", /* Uzbek" */
+"ve", /* Venda" */
+"vi", /* Vietnamese" */
+"vo", /* Volapuk" */
+"wal", /* Walamo" */
+"war", /* Waray" */
+"wen", /* Sorbian" */
+"wo", /* Wolof" */
+"xh", /* Xhosa" */
+"yao", /* Yao" */
+"yi", /* Yiddish" */
+"yo", /* Yoruba" */
+"za", /* Zhuang" */
+"zh", /* Chinese" */
+"zu", /* Zulu" */
+"zap", /* Zapotec" */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/unicase/locale-language	Sun Mar 08 14:10:58 2009 +0100
@@ -0,0 +1,34 @@
+Description:
+Language code of current locale.
+
+Files:
+lib/unicase/locale-language.c
+lib/unicase/locale-languages.gperf
+
+Depends-on:
+unicase/base
+localename
+gperf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += unicase/locale-language.c
+
+unicase/locale-languages.h: $(srcdir)/unicase/locale-languages.gperf
+	$(GPERF) -m 10 $(srcdir)/unicase/locale-languages.gperf > $@-t
+	mv $@-t $@
+BUILT_SOURCES        += unicase/locale-languages.h
+MOSTLYCLEANFILES     += unicase/locale-languages.h-t
+MAINTAINERCLEANFILES += unicase/locale-languages.h
+EXTRA_DIST           += unicase/locale-languages.h
+
+Include:
+"unicase.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
+