]>
Commit | Line | Data |
---|---|---|
5e9637c6 ÆAB |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2010 Ævar Arnfjörð Bjarmason | |
4 | # | |
5 | ||
6 | test_description="Gettext reencoding of our *.po/*.mo files works" | |
7 | ||
618200d2 | 8 | TEST_PASSES_SANITIZE_LEAK=true |
5e9637c6 ÆAB |
9 | . ./lib-gettext.sh |
10 | ||
9b9f46f5 JH |
11 | # The constants used in a tricky observation for undefined behaviour |
12 | RUNES="TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ" | |
13 | PUNTS="TILRAUN: ?? ???? ??? ?? ???? ?? ??? ????? ??????????? ??? ?? ????" | |
14 | MSGKEY="TEST: Old English Runes" | |
5e9637c6 ÆAB |
15 | |
16 | test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Icelandic' ' | |
17 | printf "TILRAUN: Halló Heimur!" >expect && | |
18 | LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: Hello World!" >actual && | |
19 | test_cmp expect actual | |
20 | ' | |
21 | ||
22 | test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Runes' ' | |
9b9f46f5 JH |
23 | printf "%s" "$RUNES" >expect && |
24 | LANGUAGE=is LC_ALL="$is_IS_locale" gettext "$MSGKEY" >actual && | |
5e9637c6 ÆAB |
25 | test_cmp expect actual |
26 | ' | |
27 | ||
28 | test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UTF-8 *.mo files / Icelandic' ' | |
29 | printf "TILRAUN: Halló Heimur!" | iconv -f UTF-8 -t ISO8859-1 >expect && | |
30 | LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: Hello World!" >actual && | |
31 | test_cmp expect actual | |
32 | ' | |
33 | ||
9b9f46f5 JH |
34 | test_expect_success GETTEXT_ISO_LOCALE 'gettext: impossible ISO-8859-1 output' ' |
35 | LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "$MSGKEY" >runes && | |
36 | case "$(cat runes)" in | |
37 | "$MSGKEY") | |
38 | say "Your system gives back the key to message catalog" | |
39 | ;; | |
40 | "$PUNTS") | |
41 | say "Your system replaces an impossible character with ?" | |
42 | ;; | |
43 | "$RUNES") | |
44 | say "Your system gives back the raw message for an impossible request" | |
45 | ;; | |
46 | *) | |
47 | say "We never saw the error behaviour your system exhibits" | |
48 | false | |
49 | ;; | |
50 | esac | |
5e9637c6 ÆAB |
51 | ' |
52 | ||
53 | test_expect_success GETTEXT_LOCALE 'gettext: Fetching a UTF-8 msgid -> UTF-8' ' | |
54 | printf "TILRAUN: ‚einfaldar‘ og „tvöfaldar“ gæsalappir" >expect && | |
55 | LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: ‘single’ and “double” quotes" >actual && | |
56 | test_cmp expect actual | |
57 | ' | |
58 | ||
59 | # How these quotes get transliterated depends on the gettext implementation: | |
60 | # | |
61 | # Debian: ,einfaldar' og ,,tvöfaldar" [GNU libintl] | |
62 | # FreeBSD: `einfaldar` og "tvöfaldar" [GNU libintl] | |
63 | # Solaris: ?einfaldar? og ?tvöfaldar? [Solaris libintl] | |
64 | # | |
65 | # Just make sure the contents are transliterated, and don't use grep -q | |
66 | # so that these differences are emitted under --verbose for curious | |
67 | # eyes. | |
68 | test_expect_success GETTEXT_ISO_LOCALE 'gettext: Fetching a UTF-8 msgid -> ISO-8859-1' ' | |
69 | LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: ‘single’ and “double” quotes" >actual && | |
70 | grep "einfaldar" actual && | |
71 | grep "$(echo tvöfaldar | iconv -f UTF-8 -t ISO8859-1)" actual | |
72 | ' | |
73 | ||
74 | test_expect_success GETTEXT_LOCALE 'gettext.c: git init UTF-8 -> UTF-8' ' | |
75 | printf "Bjó til tóma Git lind" >expect && | |
76 | LANGUAGE=is LC_ALL="$is_IS_locale" git init repo >actual && | |
77 | test_when_finished "rm -rf repo" && | |
78 | grep "^$(cat expect) " actual | |
79 | ' | |
80 | ||
81 | test_expect_success GETTEXT_ISO_LOCALE 'gettext.c: git init UTF-8 -> ISO-8859-1' ' | |
82 | printf "Bjó til tóma Git lind" >expect && | |
83 | LANGUAGE=is LC_ALL="$is_IS_iso_locale" git init repo >actual && | |
84 | test_when_finished "rm -rf repo" && | |
74615c2a | 85 | grep "^$(iconv -f UTF-8 -t ISO8859-1 <expect) " actual |
5e9637c6 ÆAB |
86 | ' |
87 | ||
88 | test_done |