12754N/A#!/bin/sh
12754N/A#
12754N/A# This script modifies configure.in, .po files, po/Makefile.in.in and so on
12754N/A# to configure l10n for Sun platforms. '--help' option shows the usage.
12754N/A#
12754N/A# CDDL HEADER START
12754N/A#
12754N/A# The contents of this file are subject to the terms of the
12754N/A# Common Development and Distribution License, Version 1.0 only
12754N/A# (the "License"). You may not use this file except in compliance
12754N/A# with the License.
4455N/A#
12754N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
12754N/A# or http://www.opensolaris.org/os/licensing.
12754N/A# See the License for the specific language governing permissions
12754N/A# and limitations under the License.
12754N/A#
12754N/A# When distributing Covered Code, include this CDDL HEADER in each
12754N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
12754N/A# If applicable, add the following below this CDDL HEADER, with the
12754N/A# fields enclosed by brackets "[]" replaced with your own identifying
12754N/A# information: Portions Copyright [yyyy] [name of copyright owner]
12754N/A#
12754N/A# CDDL HEADER END
12754N/A#
12754N/A#
12754N/A# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
12754N/A# Use is subject to license terms.
4455N/A#
4455N/A
10244N/APROGNAME=`basename $0`
14355N/APROG_VERSION=1.1
10244N/ASUN_ALL_LINGUAS="cs de es fr hu it ja ko pl pt_BR ru sv zh_CN zh_HK zh_TW"
12769N/AENABLE_COPYRIGHT=0
12754N/AENABLE_SUN_ALL_LINGUAS=0
10244N/ADISABLE_GNU_EXTENSIONS=0
10244N/AL10N_POTFILES=${L10N_POTFILES:-"no"}
10244N/ACONFIGURE=
11341N/ASED=/usr/xpg4/bin/sed
10244N/A
10244N/Ausage () {
12754N/A printf "This script modify ALL_LINGUAS parameter in configure.in file. \n"
12754N/A printf "\n"
12776N/A printf "usage: $PROGNAME Version $PROG_VERSION [OPTION...] \n"
12769N/A printf " -c, --enable-copyright Modify po/Makefile.in.in and gnome-doc-utils.make\n"
12769N/A printf " so that the copyright information is installed\n"
12769N/A printf " from .po files. intltoolize and\n"
12769N/A printf " gnome-doc-prepare need to be run before\n"
12769N/A printf " this script is run if you run them.\n"
12754N/A printf " -l, --enable-sun-linguas Modify ALL_LINGUAS for Sun translations.\n"
12754N/A printf " -p, --enable-pot Generate .pot file for internal. \n"
12754N/A printf " -x, --disable-gnu-extensions Remove GNU extensions in po/*.po files. \n"
12754N/A printf " -h, --help Show this message. \n"
12776N/A printf " -V, --version Show version. \n"
10244N/A}
10244N/A
12782N/Acheck_args_solgetopts ()
12782N/A{
12769N/A while [ $# -gt 0 ]
10244N/A do
12769N/A case "$1" in
12769N/A -c|--enable-copyright)
12782N/A ENABLE_COPYRIGHT=1;;
12782N/A -h|--help|--usage)
12769N/A usage
12769N/A exit 0;;
12769N/A -l|--enable-sun-linguas)
12782N/A ENABLE_SUN_ALL_LINGUAS=1;;
12769N/A -p|--enable-pot)
12782N/A L10N_POTFILES="yes";;
12776N/A -V|--version)
12782N/A echo $PROG_VERSION;
12776N/A exit 0;;
12769N/A -x|--disable-gnu-extensions)
12782N/A DISABLE_GNU_EXTENSIONS=1;;
12769N/A *)
12769N/A echo "$PROGNAME: processing error: $1" 1>&2
12769N/A exit 1;;
10244N/A esac
12782N/A shift
10244N/A done
12782N/A}
12782N/A
12782N/Ainit () {
12782N/A # GNU SUNWgnugetopt is not installed on Solaris.
12782N/A check_args_solgetopts $@
10244N/A
4455N/A if [ -f configure.in ] ; then
4455N/A CONFIGURE=configure.in
4467N/A elif [ -f configure.ac ] ; then
4455N/A CONFIGURE=configure.ac
4455N/A fi
4455N/A}
4455N/A
4455N/Apre_check () {
10244N/A if [ "$CONFIGURE" = "" -a $ENABLE_SUN_ALL_LINGUAS -eq 1 ] ; then
4455N/A echo "#### Not Found configure.in"
4455N/A exit 0
4455N/A fi
4455N/A
4455N/A if [ ! -d po ] ; then
4455N/A echo "#### Not Found po dir"
4455N/A exit 0
4455N/A fi
4455N/A}
4455N/A
12769N/Aconfigure_copyright ()
12769N/A{
12769N/A DQ='"'
12769N/A DL='$'
12769N/A GA='`'
12769N/A BS='\\\'
12769N/A
12769N/A if [ -f .sun-l10n-copyright ] ; then
12769N/A return 0;
12769N/A fi
12769N/A
12769N/A if [ -f po/Makefile.in.in ] ; then
12769N/A sed -e "/^install-data-yes: all/a\\
14355N/A mkdir_p=$DL(mkdir_p); $BS
14355N/A mkdir_p=$DL${DL}{mkdir_p:-${DQ}mkdir -p$DQ}; $BS
14355N/A itlocaledir=$DL(itlocaledir); $BS
14355N/A itlocaledir=$DL${DL}{itlocaledir:-${DL}(gnulocaledir)}; $BS
14355N/A itlocaledir=$DL${DL}{itlocaledir:-${DL}(localedir)}; $BS
14355N/A GETTEXT_PACKAGE=$DL(GETTEXT_PACKAGE); $BS
14355N/A GETTEXT_PACKAGE=$DL${DL}{GETTEXT_PACKAGE:-${DL}(DOMAIN)}; $BS
14355N/A $DL${DL}mkdir_p $DL(DESTDIR)$DL${DL}itlocaledir; $BS
14355N/A catalogs=$DQ$DL(CATALOGS)$DQ; $BS
14355N/A for cat in $DL${DL}catalogs; do $BS
14355N/A cat=${GA}basename $DL${DL}cat$GA; $BS
14355N/A lang=${GA}echo $DL${DL}cat | sed -e 's/${BS}.gmo$DL${DL}//'$GA; $BS
14355N/A dir=$DL(DESTDIR)$DL${DL}itlocaledir/$DL${DL}lang/LC_MESSAGES; $BS
14355N/A $DL${DL}mkdir_p $DL${DL}dir; $BS
14355N/A echo ${DQ}Copyright for $DL${DL}{GETTEXT_PACKAGE}.mo$DQ > $DL${DL}dir/$DL${DL}{GETTEXT_PACKAGE}.ui.copyright; $BS
12769N/A cat $DL${DL}lang.po | while read line; $BS
12769N/A do $BS
12769N/A is_comment=${GA}echo $DL${DL}line | grep '^#' | grep -v '^#,'$GA; $BS
12769N/A if [ x$DQ$DL${DL}is_comment$DQ = x ] ; then $BS
12769N/A break; $BS
12769N/A fi; $BS
14355N/A echo $DQ$DL${DL}line$DQ | sed -e ${DQ}s/^#$BS(.*$BS)/ ${BS}1/$DQ >> $DL${DL}dir/$DL${DL}{GETTEXT_PACKAGE}.ui.copyright; $BS
12769N/A done; $BS
12769N/A echo ${DQ}-------------------------------------------------------------$DQ $BS
14355N/A >> $DL${DL}dir/$DL${DL}{GETTEXT_PACKAGE}.ui.copyright; $BS
14355N/A echo $DQ$DQ >> $DL${DL}dir/$DL${DL}{GETTEXT_PACKAGE}.ui.copyright; $BS
14355N/A echo ${DQ}installing $DL${DL}{GETTEXT_PACKAGE}.ui.copyright in $DL${DL}dir$DQ; $BS
12769N/A done" po/Makefile.in.in >> po/Makefile.in.in.$$
12769N/A mv po/Makefile.in.in.$$ po/Makefile.in.in
12769N/A fi
12769N/A
12769N/A if [ -f gnome-doc-utils.make ] ; then
12769N/A sed -e "/^install-doc-docs:/a\\
12769N/A @for lc in $DL(_DOC_REAL_LINGUAS); do ${BS}
12769N/A echo $DQ$DL(mkinstalldirs) $DL(DESTDIR)$DL(HELP_DIR)/$DL(DOC_MODULE)/$DL${DL}lc$DQ; ${BS}
12769N/A $DL(mkinstalldirs) $DL(DESTDIR)$DL(HELP_DIR)/$DL(DOC_MODULE)/$DL${DL}lc; ${BS}
12769N/A if test -d $DQ$DL${DL}lc$DQ; then d=; else d=$DQ$DL(srcdir)/$DQ; fi; ${BS}
12769N/A if [ -f $DL${DL}d$DL${DL}lc/$DL${DL}lc.po ] ; then ${BS}
12782N/A echo ${DQ}Copyright for $DL(DOC_MODULE)$DQ >> $DL(DESTDIR)/$DL(HELP_DIR)/$DL(DOC_MODULE)/$DL${DL}lc/$DL(DOC_MODULE).help.copyright; ${BS}
12769N/A cat $DL${DL}d$DL${DL}lc/$DL${DL}lc.po | while read line; ${BS}
12769N/A do ${BS}
12769N/A is_comment=${GA}echo $DL${DL}line | grep '^#' | grep -v '^#,'$GA; ${BS}
12769N/A if [ x$DQ$DL${DL}is_comment$DQ = x ] ; then ${BS}
12769N/A break; ${BS}
12769N/A fi; ${BS}
12782N/A echo $DQ$DL${DL}line$DQ | sed -e ${DQ}s/^#$BS(.*$BS)/ ${BS}1/$DQ >> $DL(DESTDIR)/$DL(HELP_DIR)/$DL(DOC_MODULE)/$DL${DL}lc/$DL(DOC_MODULE).help.copyright; ${BS}
12769N/A done; ${BS}
12769N/A echo ${DQ}-------------------------------------------------------------$DQ ${BS}
12782N/A >> $DL(DESTDIR)/$DL(HELP_DIR)/$DL(DOC_MODULE)/$DL${DL}lc/$DL(DOC_MODULE).help.copyright; ${BS}
12782N/A echo $DQ$DQ >> $DL(DESTDIR)/$DL(HELP_DIR)/$DL(DOC_MODULE)/$DL${DL}lc/$DL(DOC_MODULE).help.copyright; ${BS}
12782N/A echo ${DQ}installing $DL(DOC_MODULE).help.copyright in $DL(DESTDIR)/$DL(HELP_DIR)/$DL(DOC_MODULE)/$DL${DL}lc$DQ; ${BS}
12769N/A fi; ${BS}
12769N/A done" gnome-doc-utils.make > gnome-doc-utils.make.$$
12769N/A mv gnome-doc-utils.make.$$ gnome-doc-utils.make
12769N/A fi
12769N/A
12769N/A touch .sun-l10n-copyright
12769N/A return 0
12769N/A}
12769N/A
12769N/A
10794N/A# GNU .po has several GNU extensions.
10794N/A# http://www.gnu.org/software/libc/manual/html_node/Formatting-Calendar-Time.html
10943N/A# http://gcc.gnu.org/ml/gcc-patches/2000-08/msg00881.html
10244N/Adisable_gnu_extensions () {
10244N/A cd po
10794N/A
10794N/A # Replace "%-m" with "%m" for strftime(3C).
10943N/A # Replace "%Id" with "%d" for printf(3C) and don't use "." for the workaround
10794N/A # Replace "%l" with "%I" for strptime(3C) and also grep %M for the workaround
10794N/A # so that we do not change %ld for printf(3C).
17925N/A # Replace "%k" and "%-H" with "%H" for strptime(3C).
10794N/A for po in `egrep -l \
17925N/A'^msgstr ".*%[_0^-][mdH].*"|'\
10943N/A'^msgstr "%I[doxXnfFeEgGaAcspCSm]"|'\
10795N/A'^msgstr ".*%[_0^-]*l.*%[MpP].*"|'\
10795N/A'^msgstr ".*%[MpP].*%[_0^-]*l.*"|'\
10794N/A'^msgstr ".*%[_0^-]*k.*"'\
10794N/A *.po`
10244N/A do
10244N/A env LANG=C LC_ALL=C \
17925N/A $SED -e '/^msgstr "/s/%[_0^-]\([mdH]\)/%\1/g' $po |
10794N/A env LANG=C LC_ALL=C \
11341N/A $SED -e 's/^\(msgstr "%\)I\([doxXnfFeEgGaAcspCSm]"\)/\1\2/g' |
10943N/A env LANG=C LC_ALL=C \
11341N/A $SED -e '/^msgstr ".*%[_0^-]*l.*%[MpP]/s/%[_0^-]*l/%I/g' |
10794N/A env LANG=C LC_ALL=C \
11341N/A $SED -e '/^msgstr ".*%[MpP].*%[_0^-]*l/s/%[_0^-]*l/%I/g' |
10794N/A env LANG=C LC_ALL=C \
11341N/A $SED -e '/^msgstr "/s/%[_0^-]*k/%H/g' > $po.$$
10244N/A mv $po.$$ $po
10244N/A done
10794N/A
13776N/A # Replace "%Id" with "%d" for printf(3C) forcibly for RTL languages only.
13776N/A for po in `egrep -l \
13776N/A'%I[doxXnfFeEgGaAcspCSm][^a-zA-Z]'\
13776N/A ar.po az.po fa.po he.po ur.po yi.po`
13776N/A do
13776N/A env LANG=C LC_ALL=C \
13776N/A $SED -e 's/\(%\)I\([doxXnfFeEgGaAcspCSm][^a-zA-Z]\)/\1\2/g' $po > $po.$$
13776N/A mv $po.$$ $po
13776N/A done
13776N/A
10244N/A cd ..
10244N/A}
10244N/A
10244N/Aapply_sun_all_linguas_file () {
10244N/A PO_LINGUAS=`cat po/LINGUAS | grep -v "^#"`
10244N/A PO_LINGUAS=`echo "$PO_LINGUAS $SUN_ALL_LINGUAS"\
10244N/A | tr " " "\n" \
10244N/A | env LC_ALL=C LANG=C sort \
10244N/A | uniq \
10244N/A | tr "\n" " "`
10244N/A
10244N/A SAVE_COMMENT=`grep "^#" po/LINGUAS`
10244N/A echo "$SAVE_COMMENT" > po/LINGUAS
10244N/A echo "$PO_LINGUAS" >> po/LINGUAS
10244N/A}
10244N/A
10244N/Aapply_sun_all_linguas_configure () {
4455N/A ALL_LINGUAS=`grep '^ALL_LINGUAS=' $CONFIGURE \
11341N/A | $SED -e 's/ALL_LINGUAS=//' -e 's/"//g'`
4455N/A ALL_LINGUAS=`echo "${ALL_LINGUAS} ${SUN_ALL_LINGUAS}"\
4455N/A | tr " " "\n" \
4455N/A | sort \
4455N/A | uniq \
4455N/A | tr "\n" " "`
4455N/A
4455N/A DQ='"'
11341N/A $SED -e "/^ALL_LINGUAS=/s/^\(ALL_LINGUAS=\)\(.*\)/\1$DQ${ALL_LINGUAS}$DQ/" \
4455N/A $CONFIGURE > ${CONFIGURE}.chg
4455N/A mv ${CONFIGURE}.chg $CONFIGURE
4455N/A}
4455N/A
10244N/Aapply_sun_all_linguas () {
10244N/A if [ -f po/LINGUAS ] ; then
10244N/A apply_sun_all_linguas_file
10244N/A else
10244N/A apply_sun_all_linguas_configure
10244N/A fi
10244N/A}
10244N/A
4455N/Aupdate_po () {
4455N/A PO_DIRS=po*/POTFILES.in
11341N/A PO_DIRS=`echo $PO_DIRS | $SED -e 's|/POTFILES.in||g'`
4455N/A
4455N/A for po in $PO_DIRS
4455N/A do
4455N/A#
4455N/A# This is needed to avoid build errors.
4455N/A#
11345N/A (cd $po; touch `echo "$SUN_ALL_LINGUAS" | $SED -e 's/\([a-z_A-Z][a-z_A-Z]*\)/\1.po/g'`)
4455N/A done
4455N/A}
4455N/A
4455N/Aupdate_pot () {
4455N/A OS=`uname -s`
4455N/A if [ "$OS" = Linux ] ; then
4455N/A TOPDIR=/usr/src/packages
4455N/A else
4455N/A TOPDIR=/jds/packages
4455N/A fi
4455N/A POT_DATA='"POT-Creation-Date: '
4455N/A
4455N/A cd po
4455N/A rm -f *.pot
4455N/A echo "[encoding: UTF-8]" > POTFILES.in
4455N/A intltool-update --maintain 2>/dev/null
4455N/A cat missing >> POTFILES.in
4455N/A intltool-update --pot
4455N/A POT=`ls *.pot`
4455N/A if [ "x$POT" != "x" ] ; then
11341N/A $SED -e "/^$POT_DATA/d" $POT > ${POT}.$$
4455N/A mv ${POT}.$$ $POT
4455N/A mkdir -p $TOPDIR/l10n/pot
4455N/A mkdir -p $TOPDIR/l10n/diff
4455N/A mkdir -p $TOPDIR/l10n/new
4455N/A if [ -f $TOPDIR/l10n/pot/$POT ] ; then
4455N/A diff $TOPDIR/l10n/pot/$POT $POT > ${POT}.diff
4455N/A if [ -s ${POT}.diff ] ; then
4455N/A cp ${POT}.diff $TOPDIR/l10n/diff
4455N/A echo "#### Translation should be updated!!!"
4455N/A fi
4455N/A else
4455N/A cp $POT $TOPDIR/l10n/pot
4455N/A cp $POT $TOPDIR/l10n/new
4455N/A fi
4455N/A else
4455N/A echo "#### Failed to create the potfile in `pwd`"
4455N/A fi
4455N/A cd ..
4455N/A}
4455N/A
4455N/Amain () {
10244N/A init $@
4455N/A pre_check
4455N/A
10244N/A if [ $DISABLE_GNU_EXTENSIONS -eq 1 ] ; then
10244N/A disable_gnu_extensions
10244N/A fi
10244N/A if [ $ENABLE_SUN_ALL_LINGUAS -eq 1 ] ; then
10244N/A apply_sun_all_linguas
10244N/A update_po
10244N/A fi
12769N/A if [ $ENABLE_COPYRIGHT -eq 1 ] ; then
12769N/A configure_copyright
12769N/A fi
4455N/A if [ "x$L10N_POTFILES" = "xyes" ] ; then
4455N/A update_pot
4455N/A fi
4455N/A}
4455N/A
10244N/Amain $@