Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translators #343

Merged
merged 4 commits into from
Jul 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove mandatory argument
jeanslack committed Jul 6, 2024
commit 6a858a0f1f4fd1160f34a236d9b26f36f5bde01f
33 changes: 10 additions & 23 deletions develop/gettext_utils/make_pot.sh
Original file line number Diff line number Diff line change
@@ -6,38 +6,25 @@
# Rev: July.05.2024
#
# PORPOSE: Create a new `videomass.pot` file with the latest strings.
# USAGE: ~$ make_pot.sh '/path/to/locale/directory'
#
# USAGE: ~$ cd /Videomass/source/directory
# ~$ develop/gettext_utils/make_pot.sh

TARGET=$1 # locale directory
TARGET="videomass/data/locale" # relative path to "locale" directory
POTFILE="$TARGET/videomass.pot" # store the new .pot file here
self="$(readlink -f -- $0)" # this file
HERE="${self%/*}" # dirname of this file
FILE_CATALOG=$(<"${HERE}/Translation_Catalog.txt")

if [ -z "$1" ]; then
echo 'Missing argument: Path to directory named "locale" is required (e.g "videomass/data/locale")'
exit 1
fi
CATALOG=$(<"${HERE}/Translation_Catalog.txt") # read catalog file

if [ -d "${TARGET}" ] ; then
echo "Target directory: '${TARGET}'";
else
if [ -f "${TARGET}" ]; then
echo "'${TARGET}' is a file";
exit 1
else
echo "'${TARGET}' is not valid";
exit 1
fi
fi
echo -e "\nTarget directory: \033[34m\e[1m'${TARGET}'\e[0m"

cd "${TARGET}"
xgettext --width=400 --default-domain videomass ${FILE_CATALOG}
xgettext --width=400 --default-domain videomass ${CATALOG}

if [ $? != 0 ]; then
echo 'Failed!'
echo -e '\e[1m\033[31mFailed!\e[0m'
else
mv videomass.po videomass.pot
echo "A new file 'videomass.pot' has been created successfully."
echo "Done!"
echo -e "\e[1m«videomass.pot» was successfully created.\e[0m"
echo -e "\033[32mDone!\e[0m"
fi
49 changes: 16 additions & 33 deletions develop/gettext_utils/update_po_files.sh
Original file line number Diff line number Diff line change
@@ -6,51 +6,34 @@
# Rev: July.05.2024
#
# PORPOSE: Updates all translation strings of videomass.po files contained in
# a given directory (usually "videomass/data/locale"). It accept
# absolute or relative path names. If `compile=true` argument is given
# it compile MO bin
# in "videomass/data/locale". If `--compile` argument is given
# it also compile MO bin files.
#
# USAGE: ~$ update_po_files.sh '/path/to/locale/directory' [compile=true]
# USAGE: ~$ cd /Videomass/source/directory
# ~$ develop/gettext_utils/update_po_files.sh [--compile]

TARGET=$1
POTFILE="$TARGET/videomass.pot"
COMPILE_MO_BIN=$2
set -e # Exit immediately if a command exits with a non-zero status.

if [ -z "$1" ]; then
echo 'Missing argument: Path to directory named "locale" is required (e.g "videomass/data/locale")'
exit 1
fi
TARGET="videomass/data/locale" # relative path to "locale" directory
POT="$TARGET/videomass.pot" # pot file
COMPILE_MO=$1 # optional positional argument

if [ -d "${TARGET}" ] ; then
echo "Target directory: '${TARGET}'";
else
if [ -f "${TARGET}" ]; then
echo "'${TARGET}' is a file";
exit 1
else
echo "'${TARGET}' is not valid";
exit 1
fi
fi
echo -e "\nTarget directory: \033[34m\e[1m'${TARGET}'\e[0m"

if [ ! -f "${POTFILE}" ]; then
echo "File not found: videomass.pot"
if [ ! -f "${POT}" ]; then
echo -e "\033[31mERROR:\e[0m File not found: videomass.pot"
exit 1
fi

for langdirs in $(ls -d ${TARGET}/*/)
do
PO="${langdirs}LC_MESSAGES/videomass.po"
msgmerge --update --no-fuzzy-matching --width=400 --no-wrap $PO $POTFILE
if [ "${COMPILE_MO_BIN}" = 'compile=true' ]; then
echo "Now compile videomass.mo file because compile=true"
msgmerge --update --no-fuzzy-matching --width=400 --no-wrap $PO $POT
if [ "${COMPILE_MO}" = '--compile' ]; then
echo 'Now Compile the videomass.mo file because the "--compile" argument is given'
msgfmt -c "${PO}" -o "${langdirs}LC_MESSAGES/videomass.mo"
fi
done

if [ $? != 0 ]; then
echo 'Failed!'
else
echo "All PO files was updated successfully."
echo "Done!"
fi
echo -e "\n\e[1mSuccessful update.\e[0m"
echo -e "\033[32mDone!\e[0m"
2 changes: 1 addition & 1 deletion videomass/data/locale/videomass.pot
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-05 22:56+0200\n"
"POT-Creation-Date: 2024-07-06 00:16+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"