[libxslt] Support Esperanto locale
- From: Daniel Veillard <veillard src gnome org>
 
- To: svn-commits-list gnome org
 
- Cc: 
 
- Subject: [libxslt] Support Esperanto locale
 
- Date: Thu, 17 Sep 2009 12:50:59 +0000 (UTC)
 
commit d65daeaf651adde15a9f34d93d8cf3f3303303ff
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Thu Sep 17 14:50:02 2009 +0200
    Support Esperanto locale
    
    * libxslt/xsltlocale.c: only affects the glibc locale code, adds
      the "eo" language code and also try locales without territory
 libxslt/xsltlocale.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/libxslt/xsltlocale.c b/libxslt/xsltlocale.c
index 142f874..ec03cde 100644
--- a/libxslt/xsltlocale.c
+++ b/libxslt/xsltlocale.c
@@ -71,8 +71,7 @@ static void xsltEnumSupportedLocales(void);
  * @languageTag: RFC 3066 language tag
  *
  * Creates a new locale of an opaque system dependent type based on the
- * language tag. Three-letter language codes (ISO 639-2 Alpha-3) are not
- * supported.
+ * language tag.
  *
  * Returns the locale or NULL on error or if no matching locale was found
  */
@@ -80,7 +79,7 @@ xsltLocale
 xsltNewLocale(const xmlChar *languageTag) {
 #ifdef XSLT_LOCALE_XLOCALE
     xsltLocale locale;
-    char localeName[XSLTMAX_LANGTAGLEN+6]; /* 8*lang + "-" + 8*region + ".utf8\0" */
+    char localeName[XSLTMAX_LANGTAGLEN+6]; /* 6 chars for ".utf8\0" */
     const xmlChar *p = languageTag;
     const char *region = NULL;
     char *q = localeName;
@@ -115,9 +114,18 @@ xsltNewLocale(const xmlChar *languageTag) {
         if (locale != NULL)
             return(locale);
         
+        /* Continue without using country code */
+        
         q = localeName + llen + 1;
     }
     
+    /* Try locale without territory, e.g. for Esperanto (eo) */
+
+    memcpy(q, ".utf8", 6);
+    locale = newlocale(LC_COLLATE_MASK, localeName, NULL);
+    if (locale != NULL)
+        return(locale);
+
     /* Try to find most common country for language */
     
     if (llen != 2)
@@ -127,6 +135,7 @@ xsltNewLocale(const xmlChar *languageTag) {
     if (region == NULL)
         return(NULL);
      
+    q = localeName + llen + 1;
     *q++ = region[0];
     *q++ = region[1];
     memcpy(q, ".utf8", 6);
@@ -216,7 +225,7 @@ xsltDefaultRegion(const xmlChar *localeName) {
             break;
         case 'e':
             if (c == 'l') region = "GR";
-            else if (c == 'n') region = "US";
+            else if (c == 'n' || c == 'o') region = "US";
             else if (c == 's' || c == 'u') region = "ES";
             else if (c == 't') region = "EE";
             break;
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]