third_party/libgpg-error/potomo
author Mozilla Releng Treescript <release+treescript@mozilla.org>
Sun, 28 Feb 2021 08:38:45 +0000
changeset 41364 34624dcfc8c02624147f09f916100d1b5588270e
parent 35382 bda21df4a78930639cea50d8a53f4c95c5a1b3d6
permissions -rwxr-xr-x
no bug - Bumping Thunderbird l10n changesets r=release a=l10n-bump DONTBUILD de -> b80994057d16938db195fb54bade418a01ca084c dsb -> 8a8fdf8cae82c27d86cd5bfb1295a9647b204bc2 en-CA -> 41432174f231ccbfb3006bcc89437350626602b9 es-AR -> 8c0c5816889fed9a603ded2d2bb888536d8011aa fr -> e642311c31ebc208eaef42f3a39a9897fea30de5 he -> b60cd8a24ce8b70f1dcc6a17e0caf3431c954ec5 hsb -> 07008a27fe75e89f4941291b69bcf66fab5106ff hu -> 8e9c8709f87fa3de1975d21a75500615bcf526b3 it -> 5f242a3e69e4cf0c663c30743e40380e9b830893 kk -> 0a71adbbe04c4fe442e5ad1de6f47abe92884e2b lt -> 463bf9ab75164a3273a2a82596cafbbff8e43264 nl -> 6adc07dcf3be7ab40bd22bf2ebf3bc0f557db716 nn-NO -> 258cfd034ad244efe2fc06f66c11ab72a774a7b3 pl -> 1b0a08999b5ff10164f859cf0a374ddfa099c973 rm -> 83e0b524606ba7b4cc61c8aa075ce07d8d633b09 sk -> b9c3e8a3cbbcbe312c8455e6f495d9bc4f9161ed tr -> 19dbba93d563c3da21a0477e7d32f6e9d930a0b8

#!/bin/sh
# potomo - Convert a .po file to an utf-8 encoded .mo file.
# Copyright 2008 g10 Code GmbH
# Copyright 2010 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# This script is used to create the mo files for applications using
# the simple gettext implementation provided by libgpg-error.  That
# gettext can only cope with utf-8 encoded mo files; thus we make this
# sure while creating the mo.  A conversion is not done if the source
# file does not exist or if it is not newer than the mo file.

if [ "$1" = "--get-linguas" -a $# -eq 2 ]; then
   if [ ! -f "$2/LINGUAS" ]; then
       echo "potomo: directory '$2' has no LINGUAS file" >&2
       exit 1
   fi
   echo $(sed -e "/^#/d" -e "s/#.*//" "$2"/LINGUAS)
   exit 0
fi

if [ $# -ne 2 ]; then
  echo "usage: potomo INFILE.PO OUTFILE.MO" >&2
  echo "       potomo --get-linguas DIR"    >&2
  exit 1
fi
infile="$1"
outfile="$2"

if [ ! -f "$infile" ]; then
  echo "potomo: '$infile' not found - ignored" 2>&1
  exit 0
fi

if [ "$outfile" -nt "$infile" ]; then
  echo "potomo: '$outfile' is newer than source - keeping" 2>&1
  exit 0
fi
  
# Note that we could use the newer msgconv.  However this tool was not
# widely available back in 2008.

fromset=`sed -n '/^"Content-Type:/ s/.*charset=\([a-zA-Z0-9_-]*\).*/\1/p' \
         "$infile"`

case "$fromset" in 
    utf8|utf-8|UTF8|UTF-8) 
        echo "potomo: '$infile' keeping $fromset" >&2 
        msgfmt --output-file="$outfile" "$infile"
        ;;   
    *)
        echo "potomo: '$infile' converting from $fromset to utf-8" >&2
        iconv --silent --from-code=$fromset --to-code=utf-8 < "$infile" |\
            sed "/^\"Content-Type:/ s/charset=[a-zA-Z0-9_-]*/charset=utf-8/"|\
            msgfmt --output-file="$outfile" -
        ;;
esac