| 1 |
#!/bin/bash |
|---|
| 2 |
# traingear -- a network enabled railroad operations simulator and utilities |
|---|
| 3 |
# Copyright (C) 2007,2008 Samuel E. Henley sehenley@comcast.net |
|---|
| 4 |
# |
|---|
| 5 |
# This program is free software; you can redistribute it and/or modify |
|---|
| 6 |
# it under the terms of the GNU General Public License as published by |
|---|
| 7 |
# the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 |
# (at your option) any later version. |
|---|
| 9 |
# |
|---|
| 10 |
# This program is distributed in the hope that it will be useful, |
|---|
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 |
# GNU General Public License for more details. |
|---|
| 14 |
# |
|---|
| 15 |
# You should have received a copy of the GNU General Public License along |
|---|
| 16 |
# with this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 17 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|---|
| 18 |
# |
|---|
| 19 |
|
|---|
| 20 |
# @ /file |
|---|
| 21 |
# @ Builds the mo files for internationalzation and update source po files. |
|---|
| 22 |
# @ /note arguments $1=${SIMULATOR_WORKING_BINARY_DIRECTORY} |
|---|
| 23 |
# @ $2=${GNU_XGETTEXT_UTILITY} |
|---|
| 24 |
# @ $3=${WXWINDOWS_WXRC_UTILITY} |
|---|
| 25 |
# @ $4=${SIMULATOR_WORKING_DIRECTORY} |
|---|
| 26 |
# @ |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
# @ /page internationalization1 Internationalization |
|---|
| 30 |
# @ /par Internationalization. |
|---|
| 31 |
# @ /note The simulator and utilities will use the GNU gettext library to do localization |
|---|
| 32 |
# @ and internationalization for both windows and linux. The primary |
|---|
| 33 |
# @ tool used will be poEdit. The build process will contain a job (INTERNATIONALIZATION) |
|---|
| 34 |
# @ that will gather strings and add then to the source files in the internationalization |
|---|
| 35 |
# @ sub-directory of src (trunk/src/internationalization). |
|---|
| 36 |
# @ This file is a combination of wxstd.po and the strings gathered from the utilities. |
|---|
| 37 |
# @ This po source will install on the user machine with instruction to |
|---|
| 38 |
# @ get poEdit to facilitate translations. |
|---|
| 39 |
# @ |
|---|
| 40 |
|
|---|
| 41 |
if [ -d $1/internationalization/tmp ] |
|---|
| 42 |
then |
|---|
| 43 |
rm --force --recursive $1/internationalization/tmp |
|---|
| 44 |
fi |
|---|
| 45 |
|
|---|
| 46 |
mkdir --parents $1/internationalization/tmp |
|---|
| 47 |
cd $1/internationalization/tmp |
|---|
| 48 |
|
|---|
| 49 |
# Collect xrc files and produce fake cpp files for xgettext. |
|---|
| 50 |
for i in $( find $4/src -iname '*.xrc' -type f ) |
|---|
| 51 |
do |
|---|
| 52 |
wxrc --gettext --cpp-code --output="$(basename $i).cpp" "$i"; |
|---|
| 53 |
done |
|---|
| 54 |
|
|---|
| 55 |
# Collect all cpp files for xgettext. |
|---|
| 56 |
find . -iname '*.cpp' -type f -print >> cppfiles.txt |
|---|
| 57 |
find $4/src -iname '*.cpp' -type f -print >> cppfiles.txt |
|---|
| 58 |
find $4/src -iname '*.h' -type f -print >> cppfiles.txt |
|---|
| 59 |
|
|---|
| 60 |
# Collect all the strings from cpp files using xgettext. |
|---|
| 61 |
xgettext --files-from=cppfiles.txt --directory= --c++ --keyword=_ --output=$1/internationalization/tmp/osrail.pot |
|---|
| 62 |
|
|---|
| 63 |
# Collect the current source po files and mearge them with the found strings. |
|---|
| 64 |
# Move the po files back, po files in the src are the place to make changes and translations. |
|---|
| 65 |
# Create a mo file for each po file, these files are discardable |
|---|
| 66 |
|
|---|
| 67 |
for j in $( find $4/src -iname '??.po' -type f ) |
|---|
| 68 |
do |
|---|
| 69 |
msgcat --use-first --output="$(basename $j)" "$j" osrail.pot |
|---|
| 70 |
cp --force "$(basename $j)" "$(dirname $j)" |
|---|
| 71 |
k="$(basename $j)" |
|---|
| 72 |
echo "$k" |
|---|
| 73 |
if [ ! -d "$1/${k%%.*}" ] |
|---|
| 74 |
then |
|---|
| 75 |
mkdir --parents "$1/${k%%.*}" |
|---|
| 76 |
fi |
|---|
| 77 |
msgfmt --output-file="$1/${k%%.*}/${k%%.*}.mo" "$k" |
|---|
| 78 |
done |
|---|
| 79 |
|
|---|
| 80 |
cd .. |
|---|
| 81 |
|
|---|
| 82 |
rm --force --recursive $1/internationalization/tmp |
|---|