Merge branch 'fixes/2.45.1/2.41' into fixes/2.45.1/2.42
[alt-git.git] / t / t0200-gettext-basic.sh
blob522fb2ae696da93e0b8bb8d430f0a4dad6cbd7b3
1 #!/bin/sh
3 # Copyright (c) 2010 Ævar Arnfjörð Bjarmason
6 test_description='Gettext support for Git'
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./lib-gettext.sh
11 test_expect_success "sanity: \$GIT_INTERNAL_GETTEXT_SH_SCHEME is set (to $GIT_INTERNAL_GETTEXT_SH_SCHEME)" '
12 test -n "$GIT_INTERNAL_GETTEXT_SH_SCHEME"
15 test_expect_success 'sanity: $TEXTDOMAIN is git' '
16 test $TEXTDOMAIN = "git"
19 test_expect_success 'xgettext sanity: Perl _() strings are not extracted' '
20 ! grep "A Perl string xgettext will not get" "$GIT_PO_PATH"/is.po
23 test_expect_success 'xgettext sanity: Comment extraction with --add-comments' '
24 grep "TRANSLATORS: This is a test" "$TEST_DIRECTORY"/t0200/* | wc -l >expect &&
25 grep "TRANSLATORS: This is a test" "$GIT_PO_PATH"/is.po | wc -l >actual &&
26 test_cmp expect actual
29 test_expect_success 'xgettext sanity: Comment extraction with --add-comments stops at statements' '
30 ! grep "This is a phony" "$GIT_PO_PATH"/is.po &&
31 ! grep "the above comment" "$GIT_PO_PATH"/is.po
34 test_expect_success GETTEXT 'sanity: $TEXTDOMAINDIR exists without NO_GETTEXT=YesPlease' '
35 test -d "$TEXTDOMAINDIR" &&
36 test "$TEXTDOMAINDIR" = "$GIT_TEXTDOMAINDIR"
39 test_expect_success GETTEXT 'sanity: Icelandic locale was compiled' '
40 test -f "$TEXTDOMAINDIR/is/LC_MESSAGES/git.mo"
43 # TODO: When we have more locales, generalize this to test them
44 # all. Maybe we'll need a dir->locale map for that.
45 test_expect_success GETTEXT_LOCALE 'sanity: gettext("") metadata is OK' '
46 # Return value may be non-zero
47 LANGUAGE=is LC_ALL="$is_IS_locale" gettext "" >zero-expect &&
48 grep "Project-Id-Version: Git" zero-expect &&
49 grep "Git Mailing List <git@vger.kernel.org>" zero-expect &&
50 grep "Content-Type: text/plain; charset=UTF-8" zero-expect &&
51 grep "Content-Transfer-Encoding: 8bit" zero-expect
54 test_expect_success GETTEXT_LOCALE 'sanity: gettext(unknown) is passed through' '
55 printf "This is not a translation string" >expect &&
56 gettext "This is not a translation string" >actual &&
57 eval_gettext "This is not a translation string" >actual &&
58 test_cmp expect actual
61 # xgettext from C
62 test_expect_success GETTEXT_LOCALE 'xgettext: C extraction of _() and N_() strings' '
63 printf "TILRAUN: C tilraunastrengur" >expect &&
64 printf "\n" >>expect &&
65 printf "Sjá '\''git help SKIPUN'\'' til að sjá hjálp fyrir tiltekna skipun." >>expect &&
66 LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: A C test string" >actual &&
67 printf "\n" >>actual &&
68 LANGUAGE=is LC_ALL="$is_IS_locale" gettext "See '\''git help COMMAND'\'' for more information on a specific command." >>actual &&
69 test_cmp expect actual
72 test_expect_success GETTEXT_LOCALE 'xgettext: C extraction with %s' '
73 printf "TILRAUN: C tilraunastrengur %%s" >expect &&
74 LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: A C test string %s" >actual &&
75 test_cmp expect actual
78 # xgettext from Shell
79 test_expect_success GETTEXT_LOCALE 'xgettext: Shell extraction' '
80 printf "TILRAUN: Skeljartilraunastrengur" >expect &&
81 LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: A Shell test string" >actual &&
82 test_cmp expect actual
85 test_expect_success GETTEXT_LOCALE 'xgettext: Shell extraction with $variable' '
86 printf "TILRAUN: Skeljartilraunastrengur með breytunni a var i able" >x-expect &&
87 LANGUAGE=is LC_ALL="$is_IS_locale" variable="a var i able" eval_gettext "TEST: A Shell test \$variable" >x-actual &&
88 test_cmp x-expect x-actual
91 # xgettext from Perl
92 test_expect_success GETTEXT_LOCALE 'xgettext: Perl extraction' '
93 printf "TILRAUN: Perl tilraunastrengur" >expect &&
94 LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: A Perl test string" >actual &&
95 test_cmp expect actual
98 test_expect_success GETTEXT_LOCALE 'xgettext: Perl extraction with %s' '
99 printf "TILRAUN: Perl tilraunastrengur með breytunni %%s" >expect &&
100 LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: A Perl test variable %s" >actual &&
101 test_cmp expect actual
104 test_expect_success GETTEXT_LOCALE 'sanity: Some gettext("") data for real locale' '
105 LANGUAGE=is LC_ALL="$is_IS_locale" gettext "" >real-locale &&
106 test -s real-locale
109 test_done