t / t0204-gettext-reencode-sanity.shon commit MinGW: update tests to handle a native eol of crlf (5f4e02e)
   1#!/bin/sh
   2#
   3# Copyright (c) 2010 Ævar Arnfjörð Bjarmason
   4#
   5
   6test_description="Gettext reencoding of our *.po/*.mo files works"
   7
   8. ./lib-gettext.sh
   9
  10# The constants used in a tricky observation for undefined behaviour
  11RUNES="TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ"
  12PUNTS="TILRAUN: ?? ???? ??? ?? ???? ?? ??? ????? ??????????? ??? ?? ????"
  13MSGKEY="TEST: Old English Runes"
  14
  15test_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
  19'
  20
  21test_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
  25'
  26
  27test_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
  31'
  32
  33test_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"
  38                ;;
  39        "$PUNTS")
  40                say "Your system replaces an impossible character with ?"
  41                ;;
  42        "$RUNES")
  43                say "Your system gives back the raw message for an impossible request"
  44                ;;
  45        *)
  46                say "We never saw the error behaviour your system exhibits"
  47                false
  48                ;;
  49        esac
  50'
  51
  52test_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
  56'
  57
  58# How these quotes get transliterated depends on the gettext implementation:
  59#
  60#   Debian:  ,einfaldar' og ,,tvöfaldar" [GNU libintl]
  61#   FreeBSD: `einfaldar` og "tvöfaldar"  [GNU libintl]
  62#   Solaris: ?einfaldar? og ?tvöfaldar?  [Solaris libintl]
  63#
  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.
  67test_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
  71'
  72
  73test_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
  78'
  79
  80test_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
  85'
  86
  87test_done