86 lines
3.6 KiB
Bash
86 lines
3.6 KiB
Bash
#! /bin/sh
|
|
|
|
tmpfiles=""
|
|
trap 'rm -fr $tmpfiles' 1 2 3 15
|
|
|
|
tmpfiles="$tmpfiles ll ll.po dataout"
|
|
: ${MSGFMT=msgfmt}
|
|
test -d ll || mkdir ll
|
|
test -d ll/LC_MESSAGES || mkdir ll/LC_MESSAGES
|
|
|
|
tmpfiles="$tmpfiles plural-2.data"
|
|
cat <<EOF > plural-2.data
|
|
hu
|
|
0
|
|
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
de
|
|
n != 1
|
|
10111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
|
fr
|
|
n>1
|
|
00111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
|
|
gd
|
|
n==1 ? 0 : n==2 ? 1 : 2
|
|
20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
|
|
lt
|
|
n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2
|
|
20111111112222222222201111111120111111112011111111201111111120111111112011111111201111111120111111112011111111222222222220111111112011111111201111111120111111112011111111201111111120111111112011111111
|
|
ru-gettext
|
|
n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2
|
|
20111222222222222222201112222220111222222011122222201112222220111222222011122222201112222220111222222011122222222222222220111222222011122222201112222220111222222011122222201112222220111222222011122222
|
|
ru-glibc
|
|
n%100/10==1 ? 2 : n%10==1 ? 0 : (n+9)%10>3 ? 2 : 1
|
|
20111222222222222222201112222220111222222011122222201112222220111222222011122222201112222220111222222011122222222222222220111222222011122222201112222220111222222011122222201112222220111222222011122222
|
|
sk
|
|
(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2
|
|
20111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
|
|
pl
|
|
n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2
|
|
20111222222222222222221112222222111222222211122222221112222222111222222211122222221112222222111222222211122222222222222222111222222211122222221112222222111222222211122222221112222222111222222211122222
|
|
sl
|
|
n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3
|
|
30122333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333012233333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
|
|
EOF
|
|
while read lang; do
|
|
read formula
|
|
read dataok
|
|
cat > ll.po <<EOF
|
|
msgid ""
|
|
msgstr ""
|
|
"MIME-Version: 1.0\n"
|
|
"Content-Type: text/plain; charset=ASCII\n"
|
|
"Content-Transfer-Encoding: 8bit\n"
|
|
"Plural-Forms: nplurals=10; plural=${formula};\n"
|
|
|
|
msgid "X"
|
|
msgid_plural "Y"
|
|
msgstr[0] "0"
|
|
msgstr[1] "1"
|
|
msgstr[2] "2"
|
|
msgstr[3] "3"
|
|
msgstr[4] "4"
|
|
msgstr[5] "5"
|
|
msgstr[6] "6"
|
|
msgstr[7] "7"
|
|
msgstr[8] "8"
|
|
msgstr[9] "9"
|
|
EOF
|
|
${MSGFMT} -o ll/LC_MESSAGES/plural.mo ll.po || exit 1
|
|
(for i in '' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
|
|
LANGUAGE= TEXTDOMAIN=plural TEXTDOMAINDIR=. \
|
|
$NGETTEXT --env LC_ALL=ll X Y ${i}0 ${i}1 ${i}2 ${i}3 ${i}4 ${i}5 ${i}6 ${i}7 ${i}8 ${i}9
|
|
done) > dataout
|
|
test "$dataok" = `cat dataout` || {
|
|
echo "Formula evaluation error for language $lang" 1>&2
|
|
echo "plural=${formula}" 1>&2
|
|
echo "Expected: $dataok" 1>&2
|
|
echo "Got: "`cat dataout` 1>&2
|
|
rm -fr $tmpfiles
|
|
exit 1
|
|
}
|
|
done < plural-2.data
|
|
|
|
rm -fr $tmpfiles
|
|
|
|
exit 0
|