t / t0200-gettext-basic.shon commit remote: add a macro for "refs/tags/*:refs/tags/*" (750d0da)
   1#!/bin/sh
   2#
   3# Copyright (c) 2010 Ævar Arnfjörð Bjarmason
   4#
   5
   6test_description='Gettext support for Git'
   7
   8. ./lib-gettext.sh
   9
  10test_expect_success "sanity: \$GIT_INTERNAL_GETTEXT_SH_SCHEME is set (to $GIT_INTERNAL_GETTEXT_SH_SCHEME)" '
  11    test -n "$GIT_INTERNAL_GETTEXT_SH_SCHEME"
  12'
  13
  14test_expect_success 'sanity: $TEXTDOMAIN is git' '
  15    test $TEXTDOMAIN = "git"
  16'
  17
  18test_expect_success 'xgettext sanity: Perl _() strings are not extracted' '
  19    ! grep "A Perl string xgettext will not get" "$GIT_PO_PATH"/is.po
  20'
  21
  22test_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
  26'
  27
  28test_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
  31'
  32
  33test_expect_success GETTEXT 'sanity: $TEXTDOMAINDIR exists without NO_GETTEXT=YesPlease' '
  34    test -d "$TEXTDOMAINDIR" &&
  35    test "$TEXTDOMAINDIR" = "$GIT_TEXTDOMAINDIR"
  36'
  37
  38test_expect_success GETTEXT 'sanity: Icelandic locale was compiled' '
  39    test -f "$TEXTDOMAINDIR/is/LC_MESSAGES/git.mo"
  40'
  41
  42# TODO: When we have more locales, generalize this to test them
  43# all. Maybe we'll need a dir->locale map for that.
  44test_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
  51'
  52
  53test_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
  58'
  59
  60# xgettext from C
  61test_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
  69'
  70
  71test_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
  75'
  76
  77# xgettext from Shell
  78test_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
  82'
  83
  84test_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
  88'
  89
  90# xgettext from Perl
  91test_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
  95'
  96
  97test_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
 101'
 102
 103test_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
 106'
 107
 108test_done