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