t / t0204-gettext-reencode-sanity.shon commit fetch: describe new refs based on where it came from (0997ada)
   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
  11test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Icelandic' '
  12    printf "TILRAUN: Halló Heimur!" >expect &&
  13    LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: Hello World!" >actual &&
  14    test_cmp expect actual
  15'
  16
  17test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Runes' '
  18    printf "TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ" >expect &&
  19    LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: Old English Runes" >actual &&
  20    test_cmp expect actual
  21'
  22
  23test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UTF-8 *.mo files / Icelandic' '
  24    printf "TILRAUN: Halló Heimur!" | iconv -f UTF-8 -t ISO8859-1 >expect &&
  25    LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: Hello World!" >actual &&
  26    test_cmp expect actual
  27'
  28
  29test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UTF-8 *.mo files / Runes' '
  30    LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: Old English Runes" >runes &&
  31
  32        if grep "^TEST: Old English Runes$" runes
  33        then
  34                say "Your system can not handle this complexity and returns the string as-is"
  35        else
  36                # Both Solaris and GNU libintl will return this stream of
  37                # question marks, so it is s probably portable enough
  38                printf "TILRAUN: ?? ???? ??? ?? ???? ?? ??? ????? ??????????? ??? ?? ????" >runes-expect &&
  39                test_cmp runes-expect runes
  40        fi
  41'
  42
  43test_expect_success GETTEXT_LOCALE 'gettext: Fetching a UTF-8 msgid -> UTF-8' '
  44    printf "TILRAUN: ‚einfaldar‘ og „tvöfaldar“ gæsalappir" >expect &&
  45    LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: ‘single’ and “double” quotes" >actual &&
  46    test_cmp expect actual
  47'
  48
  49# How these quotes get transliterated depends on the gettext implementation:
  50#
  51#   Debian:  ,einfaldar' og ,,tvöfaldar" [GNU libintl]
  52#   FreeBSD: `einfaldar` og "tvöfaldar"  [GNU libintl]
  53#   Solaris: ?einfaldar? og ?tvöfaldar?  [Solaris libintl]
  54#
  55# Just make sure the contents are transliterated, and don't use grep -q
  56# so that these differences are emitted under --verbose for curious
  57# eyes.
  58test_expect_success GETTEXT_ISO_LOCALE 'gettext: Fetching a UTF-8 msgid -> ISO-8859-1' '
  59    LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: ‘single’ and “double” quotes" >actual &&
  60    grep "einfaldar" actual &&
  61    grep "$(echo tvöfaldar | iconv -f UTF-8 -t ISO8859-1)" actual
  62'
  63
  64test_expect_success GETTEXT_LOCALE 'gettext.c: git init UTF-8 -> UTF-8' '
  65    printf "Bjó til tóma Git lind" >expect &&
  66    LANGUAGE=is LC_ALL="$is_IS_locale" git init repo >actual &&
  67    test_when_finished "rm -rf repo" &&
  68    grep "^$(cat expect) " actual
  69'
  70
  71test_expect_success GETTEXT_ISO_LOCALE 'gettext.c: git init UTF-8 -> ISO-8859-1' '
  72    printf "Bjó til tóma Git lind" >expect &&
  73    LANGUAGE=is LC_ALL="$is_IS_iso_locale" git init repo >actual &&
  74    test_when_finished "rm -rf repo" &&
  75    grep "^$(cat expect | iconv -f UTF-8 -t ISO8859-1) " actual
  76'
  77
  78test_done