Created
December 17, 2012 14:54
-
-
Save imankulov/4318857 to your computer and use it in GitHub Desktop.
Get gettext formatted plural forms from CLDR description using android2po (to do the main job) and opterator (for command line parsing)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Requirements: | |
android2po | |
opterator | |
Sample: | |
$ python android2po_plurals.py pl | |
nplurals=3; plural=((n == 1) ? 0 : ((((n % 10) >= 2 && (n % 10) <= 4) && (!((n % 100) >= 12 && (n % 100) <= 14))) && (!((n % 100) >= 22 && (n % 100) <= 24))) ? 1 : 2) | |
""" | |
from opterator import opterate | |
from android2po.convert import plural_to_gettext | |
from android2po.env import Language | |
@opterate | |
def plural_form(language): | |
nplurals, plural = plural_to_gettext(Language(language).locale.plural_form) | |
print 'nplurals=%d; plural=%s' % (nplurals, plural) | |
plural_form() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment