From 1569237b25765acc76189921e8792430e9fac189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 26 Jan 2018 11:19:58 +0100 Subject: [PATCH] Add gettext rules as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/translate/l10n-guide/issues/22 Signed-off-by: Michal Čihař --- export-gettext | 31 +++++++++++++++++++++++++++++++ gettext.csv | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100755 export-gettext create mode 100644 gettext.csv diff --git a/export-gettext b/export-gettext new file mode 100755 index 000000000..02c7fddad --- /dev/null +++ b/export-gettext @@ -0,0 +1,31 @@ +#! /usr/bin/env python3 + +# Export Gettext builtin plurals + +import re +from urllib.request import urlopen + +URL = 'http://git.savannah.gnu.org/cgit/gettext.git/plain/gettext-tools/src/plural-table.c' +MATCH = re.compile(r'\s*{\s*"([^"]*)",\s*"([^"]*)",\s*"([^"]*)"\s*},\s*') + +with urlopen(URL) as handle: + content = handle.read().decode('utf-8') + +output = [] +state = 0 +for line in content.splitlines(): + if 'plural_table' in line: + state = 1 + continue + if state == 1: + matches = MATCH.match(line) + if matches: + output.append('{};{};{};{}\n'.format( + matches[1], + matches[2], + int(matches[3].split(';', 1)[0].split('=')[1]), + matches[3].split(';', 1)[1].split('=', 1)[1].rstrip(';'), + )) + +with open('gettext.csv', 'w') as handle: + handle.writelines(sorted(output)) diff --git a/gettext.csv b/gettext.csv new file mode 100644 index 000000000..21af1c860 --- /dev/null +++ b/gettext.csv @@ -0,0 +1,37 @@ +be;Belarusian;3;(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2) +bg;Bulgarian;2;(n != 1) +cs;Czech;3;(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2 +da;Danish;2;(n != 1) +de;German;2;(n != 1) +el;Greek;2;(n != 1) +en;English;2;(n != 1) +eo;Esperanto;2;(n != 1) +es;Spanish;2;(n != 1) +et;Estonian;2;(n != 1) +fi;Finnish;2;(n != 1) +fo;Faroese;2;(n != 1) +fr;French;2;(n > 1) +ga;Irish;3;n==1 ? 0 : n==2 ? 1 : 2 +he;Hebrew;2;(n != 1) +hr;Croatian;3;(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2) +hu;Hungarian;2;(n != 1) +it;Italian;2;(n != 1) +ja;Japanese;1;0 +ko;Korean;1;0 +lt;Lithuanian;3;(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2) +lv;Latvian;3;(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2) +nb;Norwegian Bokmal;2;(n != 1) +nl;Dutch;2;(n != 1) +nn;Norwegian Nynorsk;2;(n != 1) +no;Norwegian;2;(n != 1) +pl;Polish;3;(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2) +pt;Portuguese;2;(n != 1) +pt_BR;Brazilian;2;(n > 1) +ro;Romanian;3;n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2 +ru;Russian;3;(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2) +sk;Slovak;3;(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2 +sr;Serbian;3;(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2) +sv;Swedish;2;(n != 1) +tr;Turkish;2;(n != 1) +uk;Ukrainian;3;(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2) +vi;Vietnamese;1;0