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