Making, installing and uninstalling translations

This commit is contained in:
Bob Mottram 2015-12-01 14:38:37 +00:00
parent ebdd076214
commit 192fc6a0e6
3 changed files with 42 additions and 14 deletions

View File

@ -4,7 +4,9 @@ RELEASE=1
PREFIX?=/usr/local
all:
bash -c "translate make"
debug:
bash -c "translate make"
source:
tar -cvf ../${APP}_${VERSION}.orig.tar ../${APP}-${VERSION} --exclude-vcs
gzip -f9n ../${APP}_${VERSION}.orig.tar
@ -17,6 +19,7 @@ install:
install -m 755 src/${APP}-controlpanel ${DESTDIR}${PREFIX}/bin/control
mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1
install -m 644 man/*.1.gz ${DESTDIR}${PREFIX}/share/man/man1
bash -c "translate install"
uninstall:
rm -f ${PREFIX}/share/man/man1/${APP}*.1.gz
rm -rf ${PREFIX}/share/${APP}
@ -25,6 +28,7 @@ uninstall:
rm -f ${PREFIX}/bin/mesh
rm -f ${PREFIX}/bin/meshweb
rm -rf /etc/freedombone
bash -c "translate uninstall"
clean:
rm -f \#* \.#* debian/*.substvars debian/*.log
rm -fr deb.* debian/${APP}

View File

@ -469,7 +469,7 @@ function housekeeping {
--checklist "If you don't need to do any of these things then just press Enter:" 10 76 16)
options=(1 "Regenerate ssh host keys" off
2 "Regenerate Diffie-Hellman keys" off
3 "Renew a StartSSL certificate" off)
3 "Renew a StartSSL certificate" off
4 "Renew Let's Encrypt certificate" off)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear

View File

@ -36,10 +36,15 @@ language=( fr de )
COMMAND_FILES=src/${PROJECT_NAME}*
function create_translation_files {
if [ ! -d /tmp/${PROJECT_NAME} ]; then
mkdir -p /tmp/${PROJECT_NAME}
fi
for f in $COMMAND_FILES
do
COMMAND_NAME=$(echo $f | awk -F '/' '{print $2}')
bash --dump-po-strings src/${COMMAND_NAME} | xgettext -L PO -o /tmp/${PROJECT_NAME}_${COMMAND_NAME}.pot -
bash --dump-po-strings src/${COMMAND_NAME} | xgettext -L PO -o /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot -
if [ -f /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot ]; then
for lang in "${language[@]}"
do
if [ ! -d locale/${lang} ]; then
@ -47,10 +52,11 @@ function create_translation_files {
fi
if [ ! -f locale/${lang}/${COMMAND_NAME}.po ]; then
echo "Creating ${lang} Translation file for ${COMMAND_NAME}..."
msginit -l ${lang} -i /tmp/${PROJECT_NAME}_${COMMAND_NAME}.pot -o locale/${lang}/${COMMAND_NAME}.po
msginit -l ${lang} -i /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot -o locale/${lang}/${COMMAND_NAME}.po
fi
done
rm /tmp/${PROJECT_NAME}_${COMMAND_NAME}.pot
rm /tmp/${PROJECT_NAME}/${COMMAND_NAME}.pot
fi
done
}
@ -60,13 +66,26 @@ function install_translations {
COMMAND_NAME=$(echo $f | awk -F '/' '{print $2}')
for lang in "${language[@]}"
do
if [ ! -f locale/${lang}/${COMMAND_NAME}.mo ]; then
if [ -f locale/${lang}/${COMMAND_NAME}.mo ]; then
cp locale/${lang}/${COMMAND_NAME}.mo /usr/share/locale/${lang}/${COMMAND_NAME}.mo
fi
done
done
}
function uninstall_translations {
for f in $COMMAND_FILES
do
COMMAND_NAME=$(echo $f | awk -F '/' '{print $2}')
for lang in "${language[@]}"
do
if [ -f /usr/share/locale/${lang}/${COMMAND_NAME}.mo ]; then
rm /usr/share/locale/${lang}/${COMMAND_NAME}.mo
fi
done
done
}
if [[ $1 == "make" ]]; then
create_translation_files
exit 0
@ -77,4 +96,9 @@ if [[ $1 == "install" ]]; then
exit 0
fi
if [[ $1 == "uninstall" ]]; then
uninstall_translations
exit 0
fi
exit 1