| #! /bin/sh |
| # Copyright (C) 2010 Free Software Foundation, Inc. |
| # |
| # This program is free software; you can redistribute it and/or modify |
| # it under the terms of the GNU General Public License as published by |
| # the Free Software Foundation; either version 2, or (at your option) |
| # any later version. |
| # |
| # This program is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| # GNU General Public License for more details. |
| # |
| # You should have received a copy of the GNU General Public License |
| # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| |
| # Check the creation of compiled message catalogs in Java .properties format. |
| # FIXME: Resource names with a dash maybe don't work. If so, it should be |
| # mentioned in the documentation. |
| |
| . ./defs || Exit 1 |
| |
| set -e |
| |
| cat > Makefile.am << 'END' |
| pkgresourcesdir = $(pkgdatadir)/resources |
| pkgresources_POTS = posub/foo-bar.pot |
| posub_foo_bar_pot_SOURCES = src/Hello.java |
| posub_foo_bar_pot_LINGUAS = de fr |
| posub_foo_bar_pot_CATALOGFORMAT = properties |
| EXTRA_DIST = src/Hello.java |
| END |
| |
| cat >> configure.in << 'END' |
| AM_POT_TOOLS |
| AC_OUTPUT |
| END |
| |
| mkdir src |
| cat > src/Hello.java << 'END' |
| import java.util.*; |
| import gnu.gettext.*; |
| |
| public class Hello { |
| public static void main (String[] args) { |
| ResourceBundle catalog = ResourceBundle.getBundle("foo-bar"); |
| System.out.println(GettextResource.gettext(catalog,"Hello, world!")); |
| } |
| } |
| END |
| |
| $ACLOCAL |
| $AUTOMAKE -a |
| $AUTOCONF |
| |
| # .po files for _LINGUAS. |
| mkdir posub |
| cat > posub/foo-bar-de.po << 'END' |
| msgid "" |
| msgstr "" |
| "MIME-Version: 1.0\n" |
| "Content-Type: text/plain; charset=UTF-8\n" |
| "Content-Transfer-Encoding: 8bit\n" |
| |
| msgid "Hello, world!" |
| msgstr "Hallo Welt!" |
| END |
| cat > posub/foo-bar-fr.po << 'END' |
| msgid "" |
| msgstr "" |
| "MIME-Version: 1.0\n" |
| "Content-Type: text/plain; charset=UTF-8\n" |
| "Content-Transfer-Encoding: 8bit\n" |
| |
| msgid "Hello, world!" |
| msgstr "Salut, le monde!" |
| END |
| |
| # A .po file not listed among _LINGUAS, and a junk .properties file. |
| cat > posub/foo-bar-es.po << 'END' |
| msgid "" |
| msgstr "" |
| "MIME-Version: 1.0\n" |
| "Content-Type: text/plain; charset=UTF-8\n" |
| "Content-Transfer-Encoding: 8bit\n" |
| |
| msgid "Hello, world!" |
| msgstr "Adiós, mundo!" |
| END |
| cat > posub/foo-bar-es.properties << 'END' |
| junk |
| END |
| |
| cat > expected << 'END' |
| # SOME DESCRIPTIVE TITLE. |
| # This file is put in the public domain. |
| # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| # |
| #, fuzzy |
| msgid "" |
| msgstr "" |
| "Project-Id-Version: pot-format-java1 1.0\n" |
| "Report-Msgid-Bugs-To: \n" |
| "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
| "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
| "Language-Team: LANGUAGE <LL@li.org>\n" |
| "Language: \n" |
| "MIME-Version: 1.0\n" |
| "Content-Type: text/plain; charset=CHARSET\n" |
| "Content-Transfer-Encoding: 8bit\n" |
| |
| #: src/Hello.java:7 |
| msgid "Hello, world!" |
| msgstr "" |
| END |
| |
| distdir=$me-1.0 |
| |
| for builddir in . sub; do |
| for config_options in '' 'LINGUAS="es de"'; do |
| if test $builddir = '.'; then |
| sourcedir='.' |
| else |
| sourcedir='..' |
| mkdir $builddir |
| fi |
| instdir="`pwd`/instdir" |
| cd $builddir |
| env $config_options $sourcedir/configure --prefix="$instdir" |
| $MAKE |
| |
| # Check that "make install" creates the expected .pot file, .po files |
| # and .properties files. |
| # (They are created under $sourcedir, because the files are distributed. |
| # Cf. the GNU standards, node "Makefile Basics".) |
| |
| $MAKE install |
| |
| test -f $sourcedir/posub/foo-bar.pot |
| test $builddir = '.' || test ! -r posub/foo-bar.pot |
| grep -v 'POT-Creation-Date' $sourcedir/posub/foo-bar.pot | LC_ALL=C tr -d '\r' > actual |
| diff actual $sourcedir/expected |
| rm -f actual |
| |
| test -f $sourcedir/posub/foo-bar-de.po |
| test ! -r $sourcedir/posub/foo-bar-de.properties |
| test -f $sourcedir/posub/foo-bar_de.properties |
| test -f $sourcedir/posub/foo-bar-fr.po |
| test ! -r $sourcedir/posub/foo-bar-fr.properties |
| test -f $sourcedir/posub/foo-bar_fr.properties |
| test ! -r $sourcedir/posub/foo-bar-de.mo |
| test ! -r $sourcedir/posub/foo-bar-fr.mo |
| |
| if test -z "$config_options"; then |
| # Check that "make install" installed de,po and fr.po but not es.po. |
| test -f "$instdir"/share/pot-format-java1/resources/foo-bar_de.properties |
| test -f "$instdir"/share/pot-format-java1/resources/foo-bar_fr.properties |
| test ! -r "$instdir"/share/pot-format-java1/resources/foo-bar_es.properties |
| else |
| # Check that "make install" installed de.po but not fr.po nor es.po. |
| test -f "$instdir"/share/pot-format-java1/resources/foo-bar_de.properties |
| test ! -r "$instdir"/share/pot-format-java1/resources/foo-bar_fr.properties |
| test ! -r "$instdir"/share/pot-format-java1/resources/foo-bar_es.properties |
| fi |
| test ! -r "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.properties |
| test ! -r "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.properties |
| test ! -r "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.properties |
| test ! -r "$instdir"/share/locale/de/LC_MESSAGES/foo-bar.mo |
| test ! -r "$instdir"/share/locale/fr/LC_MESSAGES/foo-bar.mo |
| test ! -r "$instdir"/share/locale/es/LC_MESSAGES/foo-bar.mo |
| |
| # Check that "make distdir" creates the expected .pot file. |
| |
| rm -f $sourcedir/posub/foo-bar.pot |
| |
| $MAKE distdir |
| |
| test -f $sourcedir/posub/foo-bar.pot |
| test $builddir = '.' || test ! -r posub/foo-bar.pot |
| grep -v 'POT-Creation-Date' $sourcedir/posub/foo-bar.pot | LC_ALL=C tr -d '\r' > actual |
| diff actual $sourcedir/expected |
| rm -f actual |
| |
| test -f $sourcedir/posub/foo-bar-de.po |
| test ! -r $sourcedir/posub/foo-bar-de.properties |
| test -f $sourcedir/posub/foo-bar_de.properties |
| test -f $sourcedir/posub/foo-bar-fr.po |
| test ! -r $sourcedir/posub/foo-bar-fr.properties |
| test -f $sourcedir/posub/foo-bar_fr.properties |
| test ! -r $sourcedir/posub/foo-bar-de.mo |
| test ! -r $sourcedir/posub/foo-bar-fr.mo |
| |
| # Check that the tarball contains posub/foo-bar-{de,fr}.{po,properties} |
| # but not the others, regardless whether LINGUAS was specified or not. |
| test -d $distdir # sanity check |
| test -f $distdir/posub/foo-bar-de.po |
| test -f $distdir/posub/foo-bar_de.properties |
| test -f $distdir/posub/foo-bar-fr.po |
| test -f $distdir/posub/foo-bar_fr.properties |
| test ! -r $distdir/posub/foo-bar-es.po |
| test ! -r $distdir/posub/foo-bar_es.properties |
| test ! -r $distdir/posub/foo-bar-de.mo |
| test ! -r $distdir/posub/foo-bar-fr.mo |
| test ! -r $distdir/posub/foo-bar-es.mo |
| |
| # Sanity check. |
| $MAKE distcheck |
| |
| # Clean up. |
| $MAKE distclean |
| rm -rf "$instdir" |
| cd $sourcedir |
| done |
| done |
| |
| : |