2015-07-27 18:13:03 +00:00
|
|
|
#!/bin/sh
|
2011-02-24 19:01:10 +00:00
|
|
|
|
|
|
|
# PCSX2 - PS2 Emulator for PCs
|
2014-04-12 10:44:38 +00:00
|
|
|
# Copyright (C) 2002-2014 PCSX2 Dev Team
|
2011-02-24 19:01:10 +00:00
|
|
|
#
|
|
|
|
# PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
# of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
# ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# PCSX2 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 PCSX2.
|
|
|
|
# If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# This script call xgettext utility to generate some nice pot (translation template) files
|
|
|
|
|
2015-07-27 18:13:03 +00:00
|
|
|
set -e
|
|
|
|
|
2011-02-24 19:01:10 +00:00
|
|
|
######################################################################
|
|
|
|
# Script configuration
|
|
|
|
######################################################################
|
2015-12-27 17:04:47 +00:00
|
|
|
VERSION=1.4.0
|
2011-06-05 19:52:38 +00:00
|
|
|
COPYRIGHT="PCSX2 Dev Team"
|
2014-04-06 09:53:57 +00:00
|
|
|
BUG_MAIL="https://github.com/PCSX2/pcsx2/issues"
|
2011-02-24 19:01:10 +00:00
|
|
|
|
2011-06-05 19:52:38 +00:00
|
|
|
GENERAL_OPTION="--sort-by-file --no-wrap --package-name=PCSX2 \
|
|
|
|
--package-version=$VERSION --msgid-bugs-address=$BUG_MAIL"
|
2011-02-24 19:01:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Build Input file list
|
|
|
|
######################################################################
|
2011-09-28 18:36:31 +00:00
|
|
|
[ ! -e pcsx2 ] && echo "pcsx2 directory not present" && exit 1;
|
|
|
|
[ ! -e common ] && echo "common directory not present" && exit 1;
|
|
|
|
[ ! -e locales ] && echo "locales directory not present" && exit 1;
|
2011-02-24 19:01:10 +00:00
|
|
|
|
|
|
|
# Build a list of all input files
|
|
|
|
input_files=""
|
|
|
|
for directory in pcsx2 common
|
|
|
|
do
|
|
|
|
for type in cpp h
|
|
|
|
do
|
|
|
|
new_input_files=`find $directory -iname "*.${type}" -print0 | xargs -0`
|
|
|
|
input_files="$input_files $new_input_files"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Generate the pot
|
|
|
|
######################################################################
|
2011-02-25 18:16:53 +00:00
|
|
|
MAIN_POT=locales/templates/pcsx2_Main.pot
|
|
|
|
MAIN_KEY1=_
|
|
|
|
MAIN_KEY2=pxL
|
2011-02-24 19:01:10 +00:00
|
|
|
|
2011-02-25 18:16:53 +00:00
|
|
|
DEV_KEY1=_d
|
2011-02-24 19:01:10 +00:00
|
|
|
DEV_KEY2=pxDt
|
|
|
|
|
2011-02-25 18:16:53 +00:00
|
|
|
TER_KEY1=_t
|
|
|
|
TER_KEY2=pxLt
|
|
|
|
TER_KEY3=pxEt
|
2011-02-24 19:01:10 +00:00
|
|
|
|
2011-02-25 18:16:53 +00:00
|
|
|
echo "Generate $MAIN_POT"
|
2011-06-05 19:52:38 +00:00
|
|
|
xgettext --keyword=$MAIN_KEY1 --keyword=$MAIN_KEY2 --keyword=$DEV_KEY1 --keyword=$DEV_KEY2 \
|
|
|
|
--keyword=$TER_KEY1 --keyword=$TER_KEY2 $GENERAL_OPTION --copyright-holder="$COPYRIGHT" \
|
|
|
|
$input_files --output=$MAIN_POT
|
2011-02-25 18:16:53 +00:00
|
|
|
sed --in-place $MAIN_POT --expression=s/charset=CHARSET/charset=UTF-8/
|
2011-02-24 19:01:10 +00:00
|
|
|
|
2012-08-12 07:26:39 +00:00
|
|
|
ICO_POT=locales/templates/pcsx2_Iconized.pot
|
|
|
|
ICO_KEY1=pxE
|
|
|
|
|
2011-02-25 18:16:53 +00:00
|
|
|
echo "Generate $ICO_POT"
|
2011-06-05 19:52:38 +00:00
|
|
|
xgettext --keyword=$ICO_KEY1 --keyword=$TER_KEY3 $GENERAL_OPTION --copyright-holder="$COPYRIGHT" \
|
|
|
|
$input_files --output=$ICO_POT
|
2011-02-25 18:16:53 +00:00
|
|
|
sed --in-place $ICO_POT --expression=s/charset=CHARSET/charset=UTF-8/
|
2011-02-24 19:01:10 +00:00
|
|
|
|
2011-03-07 18:54:48 +00:00
|
|
|
######################################################################
|
|
|
|
# Add poedit metadata
|
|
|
|
# It eases poedit for translators
|
|
|
|
######################################################################
|
|
|
|
# Metadata example
|
|
|
|
# "X-Poedit-KeywordsList: pxE_dev;pxDt\n"
|
|
|
|
# "X-Poedit-SourceCharset: utf-8\n"
|
|
|
|
# "X-Poedit-Basepath: trunk\\\n"
|
|
|
|
# "X-Poedit-SearchPath-0: pcsx2\n"
|
|
|
|
# "X-Poedit-SearchPath-1: common\n"
|
|
|
|
# Normally "...Content-Transfer-Encoding..." is the end of the header. Use it as anchor to place poedit metadata after
|
|
|
|
COMMON_META="\"X-Poedit-SourceCharset: utf-8\\\n\"\n\"X-Poedit-Basepath: trunk\\\\\\\\\\\n\"\n\"X-Poedit-SearchPath-0: pcsx2\\\n\"\n\"X-Poedit-SearchPath-1: common\\\n\""
|
2011-06-05 20:02:54 +00:00
|
|
|
sed --in-place $MAIN_POT --expression=s/'\"Content-Transfer-Encoding: 8bit\\n\"'/"\"Content-Transfer-Encoding: 8bit\\\n\"\n\"X-Poedit-KeywordsList: ${MAIN_KEY1};${MAIN_KEY2};${DEV_KEY1};${DEV_KEY2};${TER_KEY1};${TER_KEY2}\\\n\"\n${COMMON_META}"/
|
|
|
|
sed --in-place $ICO_POT --expression=s/'\"Content-Transfer-Encoding: 8bit\\n\"'/"\"Content-Transfer-Encoding: 8bit\\\n\"\n\"X-Poedit-KeywordsList: ${ICO_KEY1};${TER_KEY3}\\\n\"\n${COMMON_META}"/
|
2011-03-07 18:54:48 +00:00
|
|
|
|
2011-02-25 18:16:53 +00:00
|
|
|
######################################################################
|
|
|
|
# Automatically align the .po to the new pot file
|
|
|
|
######################################################################
|
|
|
|
echo "Update pcsx2_Main.po files"
|
|
|
|
for po_file in `find ./locales -iname pcsx2_Main.po`
|
|
|
|
do
|
2014-07-30 07:18:15 +00:00
|
|
|
# Note: --previous corrupt po file
|
|
|
|
msgmerge --update $po_file $MAIN_POT
|
2011-02-25 18:16:53 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
echo "Update pcsx2_Iconized.po files"
|
|
|
|
for po_file in `find ./locales -iname pcsx2_Iconized.po`
|
|
|
|
do
|
2014-07-30 07:18:15 +00:00
|
|
|
# Note: --previous corrupt po file
|
|
|
|
msgmerge --update $po_file $ICO_POT
|
2011-02-25 18:16:53 +00:00
|
|
|
done
|
|
|
|
|
2011-03-21 17:42:18 +00:00
|
|
|
######################################################################
|
|
|
|
# Automatically compile po into mo file
|
|
|
|
######################################################################
|
|
|
|
echo "Compile po files, result are directly installed on bin/Langs directory"
|
|
|
|
for po_file in `find ./locales -iname "pcsx2_*.po"`
|
|
|
|
do
|
|
|
|
mo_file=`echo $po_file | sed -e 's/locales/bin\/Langs/' | sed -e 's/\.po/.mo/'`
|
|
|
|
mkdir -p `dirname $mo_file`
|
|
|
|
msgfmt -o $mo_file $po_file
|
|
|
|
done
|
2014-03-23 13:28:42 +00:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Clean garbage
|
|
|
|
######################################################################
|
|
|
|
find ./locales -iname "pcsx2_*.po~" -exec rm {} \;
|