gnome-terminal/apply-extra-translations
2010-05-05 03:12:37 +00:00

53 lines
1.6 KiB
Bash
Executable File

#! /bin/bash
# This script is a hack to extract translations for some strings from
# the gedit translations and append them to the gnome-terminal translations.
#
# To apply translations, use:
# ./apply-extra-translations --apply gnome-terminal-2.28.0 extra-translations
#
# To update the translations, use:
# ./apply-extra-translations --update gnome-terminal-2.28.0 extra-translations
if [ $# -ne 3 ]; then
echo "Usage: apply-extra-translations [--update|--apply] DIRECTORY FILE"
exit 1
fi
mode=$1
dir=$2
translations=$3
gedit_strings=("_Search" "_Find..." "Find Ne_xt" "Find Pre_vious" "Find" "_Search for: " "_Match case" "Match _entire word only" "Match as _regular expression" "Search _backwards" "_Wrap around")
our_strings=("_Search" "_Find..." "Find Ne_xt" "Find Pre_vious" "Find" "_Search for:" "_Match case" "Match _entire word only" "Match as _regular expression" "Search _backwards" "_Wrap around")
if [ "$mode" = "--update" ]; then
if ! rpm -q gedit >/dev/null ; then
echo "Please install gedit"
exit 1
fi
for l in `grep -v "^#" $dir/po/LINGUAS`; do
for s in "${gedit_strings[@]}"; do
msgstr=`env LANGUAGE="$l.UTF-8" gettext --domain=gedit "$s"`
echo "$l@$s@$msgstr"
done
done >$translations
elif [ "$mode" = "--apply" ]; then
for l in `grep -v "^#" $dir/po/LINGUAS`; do
for (( i = 0; i < ${#our_strings[@]}; i++ )) ; do
s=${gedit_strings[$i]}
msgid=${our_strings[$i]}
msgstr=`grep "^$l@$s@" $translations | cut -d@ -f3`
cat >>$dir/po/$l.po <<EOF
msgid "$msgid"
msgstr "$msgstr"
EOF
done
done
fi
exit