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 PREFIX?=/usr/local
all: all:
bash -c "translate make"
debug: debug:
bash -c "translate make"
source: source:
tar -cvf ../${APP}_${VERSION}.orig.tar ../${APP}-${VERSION} --exclude-vcs tar -cvf ../${APP}_${VERSION}.orig.tar ../${APP}-${VERSION} --exclude-vcs
gzip -f9n ../${APP}_${VERSION}.orig.tar gzip -f9n ../${APP}_${VERSION}.orig.tar
@ -17,6 +19,7 @@ install:
install -m 755 src/${APP}-controlpanel ${DESTDIR}${PREFIX}/bin/control install -m 755 src/${APP}-controlpanel ${DESTDIR}${PREFIX}/bin/control
mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1 mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1
install -m 644 man/*.1.gz ${DESTDIR}${PREFIX}/share/man/man1 install -m 644 man/*.1.gz ${DESTDIR}${PREFIX}/share/man/man1
bash -c "translate install"
uninstall: uninstall:
rm -f ${PREFIX}/share/man/man1/${APP}*.1.gz rm -f ${PREFIX}/share/man/man1/${APP}*.1.gz
rm -rf ${PREFIX}/share/${APP} rm -rf ${PREFIX}/share/${APP}
@ -25,6 +28,7 @@ uninstall:
rm -f ${PREFIX}/bin/mesh rm -f ${PREFIX}/bin/mesh
rm -f ${PREFIX}/bin/meshweb rm -f ${PREFIX}/bin/meshweb
rm -rf /etc/freedombone rm -rf /etc/freedombone
bash -c "translate uninstall"
clean: clean:
rm -f \#* \.#* debian/*.substvars debian/*.log rm -f \#* \.#* debian/*.substvars debian/*.log
rm -fr deb.* debian/${APP} 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) --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 options=(1 "Regenerate ssh host keys" off
2 "Regenerate Diffie-Hellman 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) 4 "Renew Let's Encrypt certificate" off)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear clear

View File

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