65 lines
1.9 KiB
Bash
65 lines
1.9 KiB
Bash
|
#!/bin/bash
|
||
|
# generate_translations.sh
|
||
|
# Description: A small script to create gettext translation files .pot, .po for files in files-F123Light
|
||
|
#
|
||
|
# Copyright 2019, F123 Consulting, <information@f123.org>
|
||
|
# Copyright 2019, Storm Dragon, <storm_dragon@linux-a11y.org>
|
||
|
#
|
||
|
# This 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 3, or (at your option) any later
|
||
|
# version.
|
||
|
#
|
||
|
# This software 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 package; see the file COPYING. If not, write to the Free
|
||
|
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||
|
# 02110-1301, USA.
|
||
|
#
|
||
|
#--code--
|
||
|
|
||
|
# this script must be ran inside files-F123light/
|
||
|
# get a list of files to translate.
|
||
|
fileList=($(find files/usr/lib/F123-wrappers -type f))
|
||
|
|
||
|
# Weed out the files that do not mention gettext
|
||
|
for i in "${!fileList[@]}" ; do
|
||
|
if ! grep -q "gettext" "${fileList[i]}" ; then
|
||
|
unset "fileList[i]"
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
for i in ${fileList[@]} ; do
|
||
|
echo "$i"
|
||
|
done
|
||
|
|
||
|
exit 0
|
||
|
for i in ${fileList[@]} ; do
|
||
|
# Get the directory name for each file.
|
||
|
outFile="${i##*/}"
|
||
|
outFile="${outFile%.*}"
|
||
|
echo "$outFile"
|
||
|
done
|
||
|
|
||
|
exit 0
|
||
|
|
||
|
xgettext -o ${projectName}.pot -d ${projectName} -L python $(find ../src -iname "*.py")
|
||
|
|
||
|
|
||
|
if [[ $# -eq 1 ]]; then
|
||
|
if grep -qw "$1" /etc/locale.gen ; then
|
||
|
echo "Generating .po file for $1."
|
||
|
msginit -i "${projectName}.pot" -l $1
|
||
|
sed -i -e "s/PACKAGE package.$/PACKAGE $projectName./g" \
|
||
|
-e 's/THE PACKAGE.S COPYRIGHT HOLDER$/F123 Consulting <info@f123.org>/' "${1%.*}.po"
|
||
|
else
|
||
|
echo "No locale $1 found, skipping."
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
exit 0
|