bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gettext] Plural rule definitions


From: Michele Locati
Subject: Re: [bug-gettext] Plural rule definitions
Date: Tue, 24 Feb 2015 10:45:20 +0100

2015-02-11 8:29 GMT+01:00 Michele Locati <address@hidden>:
2015-02-11 1:40 GMT+01:00 Daiki Ueno <address@hidden>:
Michele Locati <address@hidden> writes:

> I just finished a little tool that converts the plural rules from the
> CLDR format to the gettext format.

Looks like a useful tool.  Perhaps msginit (plural-table.c) could use
the generated data.

 
What about a structure like this?

// In plural-table.h
struct plural_table_entry
{
  const char *lang;
  const char *language;
  const char *value;
  const char **cases;
  const char **examples;
};

// In plural-table.c
struct plural_table_entry plural_table[] = {
  {
    "af",
    "Afrikaans",
    "nplurals=2; plural=n != 1",
    {"one", "other"},
    {"1", "0, 2~16, 100, 1000, 10000, 100000, 1000000, ..."}
  },
  {
    "ak",
    "Akan",
    "nplurals=2; plural=n > 1",
    {"one", "other"},
    {"0, 1", "2~17, 100, 1000, 10000, 100000, 1000000, ..."}
  },
  {
    "am",
    "Amharic",
    "nplurals=2; plural=n > 1",
    {"one", "other"},
    {"0, 1", "2~17, 100, 1000, 10000, 100000, 1000000, ..."}
  },
  {
    "ar",
    "Arabic",
    "nplurals=6; plural=(n == 0) ? 0 : ((n == 1) ? 1 : ((n == 2) ? 2 : ((n % 100 >= 3 && n % 100 <= 10) ? 3 : ((n % 100 >= 11 && n % 100 <= 99) ? 4 : 5))))",
    {"zero", "one", "two", "few", "many", "other"},
    {"0", "1", "2", "3~10, 103~110, 1003, ...", "11~26, 111, 1011, ...", "100~102, 200~202, 300~302, 400~402, 500~502, 600, 1000, 10000, 100000, 1000000, ..."}
  },
  // ...
  {
    "zh",
    "Chinese",
    "nplurals=1; plural=0",
    {"other"},
    {"0~15, 100, 1000, 10000, 100000, 1000000, ..."}
  },
  {
    "zu",
    "Zulu",
    "nplurals=2; plural=n > 1",
    {"one", "other"},
    {"0, 1", "2~17, 100, 1000, 10000, 100000, 1000000, ..."}
  }
};



reply via email to

[Prev in Thread] Current Thread [Next in Thread]