From bae7e4cfca848f86a712081ec1c02ec45e899b44 Mon Sep 17 00:00:00 2001 From: Johan Smith Agudelo Rodriguez Date: Sat, 18 Feb 2017 12:13:47 -0500 Subject: [PATCH] removing intltool dependence and locale scripts improved --- po/Messages.sh | 275 +++++------------- .../containment.metadata.desktop.template | 4 +- .../latte-dock.desktop.template | 7 +- .../plasmoid.metadata.desktop.template | 8 +- .../shell.metadata.desktop.template | 4 +- po/update-metadata.sh | 41 +-- 6 files changed, 111 insertions(+), 228 deletions(-) mode change 100644 => 100755 po/Messages.sh rename containment.metadata.desktop.template => po/desktop-templates/containment.metadata.desktop.template (89%) rename latte-dock.desktop.template => po/desktop-templates/latte-dock.desktop.template (73%) rename plasmoid.metadata.desktop.template => po/desktop-templates/plasmoid.metadata.desktop.template (89%) rename shell.metadata.desktop.template => po/desktop-templates/shell.metadata.desktop.template (84%) mode change 100644 => 100755 po/update-metadata.sh diff --git a/po/Messages.sh b/po/Messages.sh old mode 100644 new mode 100755 index 9110a7e5a..b0b1bc4f8 --- a/po/Messages.sh +++ b/po/Messages.sh @@ -1,206 +1,87 @@ #!/bin/sh -BASEDIR="../.." # root of translatable sources -PROJECT="plasma_applet_org.kde.latte.containment" # project name -PROJECTPATH="../../containment" # project path +BASEDIR="$(pwd $(dirname $0))" # root of translatable sources BUGADDR="https://github.com/psifidotos/latte-dock/" # MSGID-Bugs -WDIR="`pwd`/containment" # working dir + +cd "$BASEDIR/.." + +PROJECTCONTAINMENT="plasma_applet_org.kde.latte.containment" # project name +TEMPLATECONTCONTAINMENT="containment.metadata.desktop.template" # containment desktop template PROJECTPLASMOID="plasma_applet_org.kde.latte.plasmoid" # project name -PROJECTPATHPLASMOID="../../plasmoid" # project path -WDIRPLASMOID="`pwd`/plasmoid" # working dir +TEMPLATEPLASMOID="plasmoid.metadata.desktop.template" # plasmoid desktop template PROJECTSHELL="plasma_shell_org.kde.latte.shell" # project name -PROJECTPATHSHELL="../../shell" # project path -WDIRSHELL="`pwd`/shell" # working dir +TEMPLATESHELL="shell.metadata.desktop.template" # shell desktop template PROJECTAPP="latte-dock" # project name -PROJECTPATHAPP="../../app" # project path -WDIRAPP="`pwd`/app" # working dir - -echo "Preparing rc files for panel" - -cd containment - -# we use simple sorting to make sure the lines do not jump around too much from system to system -find "${PROJECTPATH}" -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > "${WDIR}/rcfiles.list" -xargs --arg-file="${WDIR}/rcfiles.list" extractrc > "${WDIR}/rc.cpp" - - -intltool-extract --quiet --type=gettext/ini ../../containment.metadata.desktop.template - -cat ../../containment.metadata.desktop.template.h >> ${WDIR}/rc.cpp - -rm ../../containment.metadata.desktop.template.h - -echo "Done preparing rc files for panel" -echo "Extracting messages for panel" - -# see above on sorting -find "${PROJECTPATH}" -name '*.cpp' -o -name '*.h' -o -name '*.c' -o -name '*.qml' -o -name '*.qml.cmake' | sort > "${WDIR}/infiles.list" -echo "rc.cpp" >> "${WDIR}/infiles.list" - -xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 \ - -ktr2i18n:1 -kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kN_:1 -kaliasLocale -kki18n:1 -kki18nc:1c,2 \ - -kki18np:1,2 -kki18ncp:1c,2,3 --msgid-bugs-address="${BUGADDR}" --files-from=infiles.list \ - -D "${BASEDIR}" -D "${WDIR}" -o "${PROJECT}.pot" || \ - { echo "error while calling xgettext. aborting."; exit 1; } -echo "Done extracting messages for panel" - -echo "Merging translations for panel" -catalogs=`find . -name '*.po'` -for cat in $catalogs; do - echo "$cat" - msgmerge -o "$cat.new" "$cat" "${WDIR}/${PROJECT}.pot" - mv "$cat.new" "$cat" -done - -intltool-merge --quiet --desktop-style . ../../containment.metadata.desktop.template "${PROJECTPATH}"/metadata.desktop.cmake - -echo "Done merging translations for panel" -echo "Cleaning up" -rm "${WDIR}/rcfiles.list" -rm "${WDIR}/infiles.list" -rm "${WDIR}/rc.cpp" -echo "Done translations for panel" - -#---------------------- Plasmoid section ----------------# - -echo "Preparing rc files for plasmoid" -cd ../plasmoid - -# we use simple sorting to make sure the lines do not jump around too much from system to system -find "${PROJECTPATHPLASMOID}" -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > "${WDIRPLASMOID}/rcfiles.list" -xargs --arg-file="${WDIRPLASMOID}/rcfiles.list" extractrc > "${WDIRPLASMOID}/rc.cpp" - -intltool-extract --quiet --type=gettext/ini ../../plasmoid.metadata.desktop.template -cat ../../plasmoid.metadata.desktop.template.h >> ${WDIRPLASMOID}/rc.cpp -rm ../../plasmoid.metadata.desktop.template.h - -echo "Done preparing rc files for plasmoid" -echo "Extracting messages for plasmoid" - -# see above on sorting - -find "${PROJECTPATHPLASMOID}" -name '*.cpp' -o -name '*.h' -o -name '*.c' -o -name '*.qml' -o -name '*.qml.cmake' | sort > "${WDIRPLASMOID}/infiles.list" -echo "rc.cpp" >> "${WDIRPLASMOID}/infiles.list" - -xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 \ - -ktr2i18n:1 -kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kN_:1 -kaliasLocale -kki18n:1 -kki18nc:1c,2 \ - -kki18np:1,2 -kki18ncp:1c,2,3 --msgid-bugs-address="${BUGADDR}" --files-from=infiles.list \ - -D "${BASEDIR}" -D "${WDIRPLASMOID}" -o "${PROJECTPLASMOID}.pot" || \ - { echo "error while calling xgettext. aborting."; exit 1; } -echo "Done extracting messages for plasmoid" - -echo "Merging translations for plasmoid" -catalogs=`find . -name '*.po'` -for cat in $catalogs; do - echo "$cat" - msgmerge -o "$cat.new" "$cat" "${WDIRPLASMOID}/${PROJECTPLASMOID}.pot" - mv "$cat.new" "$cat" -done - -intltool-merge --quiet --desktop-style . ../../plasmoid.metadata.desktop.template "${PROJECTPATHPLASMOID}"/metadata.desktop.cmake - -echo "Done merging translations for plasmoid" -echo "Cleaning up for plasmoid" -rm "${WDIRPLASMOID}/rcfiles.list" -rm "${WDIRPLASMOID}/infiles.list" -rm "${WDIRPLASMOID}/rc.cpp" -echo "Done" - - -#---------------------- Shell Section ----------------# -echo "Preparing rc files for shell" -cd ../shell - -echo "Disabling shell translations except the metadata file" - -# we use simple sorting to make sure the lines do not jump around too much from system to system -#find "${PROJECTPATHSHELL}" -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > "${WDIRSHELL}/rcfiles.list" -#xargs --arg-file="${WDIRSHELL}/rcfiles.list" extractrc > "${WDIRSHELL}/rc.cpp" - -intltool-extract --quiet --type=gettext/ini ../../shell.metadata.desktop.template -cat ../../shell.metadata.desktop.template.h >> ${WDIRSHELL}/rc.cpp -rm ../../shell.metadata.desktop.template.h - -echo "Done preparing rc files for shell" -echo "Extracting messages for shell" - -# see above on sorting - -#find "${PROJECTPATHSHELL}" -name '*.cpp' -o -name '*.h' -o -name '*.c' -o -name '*.qml' -o -name '*.qml.cmake' | sort > "${WDIRSHELL}/infiles.list" -echo "rc.cpp" >> "${WDIRSHELL}/infiles.list" - -xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 \ - -ktr2i18n:1 -kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kN_:1 -kaliasLocale -kki18n:1 -kki18nc:1c,2 \ - -kki18np:1,2 -kki18ncp:1c,2,3 --msgid-bugs-address="${BUGADDR}" --files-from=infiles.list \ - -D "${BASEDIR}" -D "${WDIRSHELL}" -o "${PROJECTSHELL}.pot" || \ - { echo "error while calling xgettext. aborting."; exit 1; } -echo "Done extracting messages for shell" - -echo "Merging translations for shell" -catalogs=`find . -name '*.po'` -for cat in $catalogs; do - echo "$cat" - msgmerge -o "$cat.new" "$cat" "${WDIRSHELL}/${PROJECTSHELL}.pot" - mv "$cat.new" "$cat" -done - -intltool-merge --quiet --desktop-style . ../../shell.metadata.desktop.template "${PROJECTPATHSHELL}"/metadata.desktop.cmake - -echo "Done merging translations for shell" -echo "Cleaning up for shell" -#rm "${WDIRSHELL}/rcfiles.list" -rm "${WDIRSHELL}/infiles.list" -rm "${WDIRSHELL}/rc.cpp" -echo "Done" - - -#---------------------- Corona Section ----------------# -echo "Preparing rc files for app" -cd ../app - -# we use simple sorting to make sure the lines do not jump around too much from system to system -find "${PROJECTPATHSHELL}" -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > "${WDIRAPP}/rcfiles.list" -find "${PROJECTPATHAPP}" -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort >> "${WDIRAPP}/rcfiles.list" -xargs --arg-file="${WDIRAPP}/rcfiles.list" extractrc > "${WDIRAPP}/rc.cpp" - -intltool-extract --quiet --type=gettext/ini ../../latte-dock.desktop.template -cat ../../latte-dock.desktop.template.h >> ${WDIRAPP}/rc.cpp -rm ../../latte-dock.desktop.template.h - -echo "Done preparing rc files for app" -echo "Extracting messages for app" - -# see above on sorting - -find "${PROJECTPATHSHELL}" -name '*.cpp' -o -name '*.h' -o -name '*.c' -o -name '*.qml' -o -name '*.qml.cmake' | sort > "${WDIRAPP}/infiles.list" -find "${PROJECTPATHAPP}" -name '*.cpp' -o -name '*.h' -o -name '*.c' -o -name '*.qml' -o -name '*.qml.cmake' | sort >> "${WDIRAPP}/infiles.list" -echo "rc.cpp" >> "${WDIRAPP}/infiles.list" - -xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 \ - -ktr2i18n:1 -kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kN_:1 -kaliasLocale -kki18n:1 -kki18nc:1c,2 \ - -kki18np:1,2 -kki18ncp:1c,2,3 --msgid-bugs-address="${BUGADDR}" --files-from=infiles.list \ - -D "${BASEDIR}" -D "${WDIRAPP}" -o "${PROJECTAPP}.pot" || \ - { echo "error while calling xgettext. aborting."; exit 1; } -echo "Done extracting messages for app" - -echo "Merging translations for app" -catalogs=`find . -name '*.po'` -for cat in $catalogs; do - echo "$cat" - msgmerge -o "$cat.new" "$cat" "${WDIRAPP}/${PROJECTAPP}.pot" - mv "$cat.new" "$cat" -done - -intltool-merge --quiet --desktop-style . ../../latte-dock.desktop.template "${PROJECTPATHAPP}"/latte-dock.desktop - -echo "Done merging translations for app" -echo "Cleaning up for app" -rm "${WDIRAPP}/rcfiles.list" -rm "${WDIRAPP}/infiles.list" -rm "${WDIRAPP}/rc.cpp" -echo "Done" - - +TEMPLATEAPP="latte-dock.desktop.template" # app desktop template + +function ki18n_xgettext +{ + cd "$BASEDIR/$1" + + WDIR="." # working dir + ROOT="../../" + PROJECTNAME=$2 # project name + TEMPLATE=$3 # desktop template + PROJECTPATH="../../$1" # project path + PROJECTPATH2= #extra project path + TARGET="\e[0;32m$1\e[0m" + + if [ $4 ] ; then + PROJECTPATH2="../../$4" + TARGET="$TARGET and \e[0;32m$4\e[0m" + else + PROJECTPATH2=$PROJECTPATH # extra project path + fi + + echo -e "-- Preparing rc files for $TARGET" + find "${PROJECTPATH}" "${PROJECTPATH2}" -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > "${WDIR}/rcfiles.list" + xargs --no-run-if-empty --arg-file="${WDIR}/rcfiles.list" extractrc > "${WDIR}/rc.cpp" + echo "rc.cpp" > "${WDIR}/infiles.list" + echo -e "-- Done preparing rc files for $TARGET" + + echo -e "-- Extracting messages for $TARGET" + find "${PROJECTPATH}" "${PROJECTPATH2}" -name '*.cpp' -o -name '*.h' -o -name '*.c' -o -name '*.qml' -o -name '*.qml.cmake' | sort >> "${WDIR}/infiles.list" + + xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 \ + -ktr2i18n:1 -kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kN_:1 -kaliasLocale -kki18n:1 -kki18nc:1c,2 \ + -kki18np:1,2 -kki18ncp:1c,2,3 --msgid-bugs-address="${BUGADDR}" --files-from=infiles.list \ + -D "${WDIR}" -o "${WDIR}/${PROJECTNAME}.pot" || \ + { echo "error while calling xgettext. aborting."; exit 1; } + + xgettext --from-code=UTF-8 --language=Desktop --join-existing --msgid-bugs-address="${BUGADDR}" \ + -k -kName -kGenericName -kComment \ + "${WDIR}/../desktop-templates/${TEMPLATE}" -o "${WDIR}/${PROJECTNAME}.pot" || \ + { echo "error while calling xgettext. aborting."; exit 1; } + + echo -e "-- Merging translations for $TARGET" + catalogs=$(find "${WDIR}" -name '*.po') + for cat in $catalogs; do + echo "${cat}" + msgmerge -o "${cat}.new" "${cat}" "${PROJECTNAME}.pot" + mv "${cat}.new" "${cat}" + done + echo -e "-- Done merging translations for $TARGET" + + echo "-- Cleaning up" + rm "rcfiles.list" + rm "infiles.list" + rm "rc.cpp" + + echo -e "-- Done translations for $TARGET\n\n" +} + +ki18n_xgettext containment "$PROJECTCONTAINMENT" "$TEMPLATECONTCONTAINMENT" + +ki18n_xgettext plasmoid "$PROJECTPLASMOID" "$TEMPLATEPLASMOID" + +ki18n_xgettext app "$PROJECTAPP" "$TEMPLATEAPP" shell + +# The msg of shell package is merged with app +# ki18n_xgettext shell "$PROJECTSHELL" "$TEMPLATESHELL" + + +cd $BASEDIR +bash ./update-metadata.sh diff --git a/containment.metadata.desktop.template b/po/desktop-templates/containment.metadata.desktop.template similarity index 89% rename from containment.metadata.desktop.template rename to po/desktop-templates/containment.metadata.desktop.template index b0535b578..c35488369 100644 --- a/containment.metadata.desktop.template +++ b/po/desktop-templates/containment.metadata.desktop.template @@ -1,7 +1,7 @@ [Desktop Entry] Encoding=UTF-8 -_Name=Latte -_Comment=Containment provided for the Latte Dock +Name=Latte +Comment=Containment provided for the Latte Dock Type=Service Keywords= diff --git a/latte-dock.desktop.template b/po/desktop-templates/latte-dock.desktop.template similarity index 73% rename from latte-dock.desktop.template rename to po/desktop-templates/latte-dock.desktop.template index 63cb258a7..c25143a83 100644 --- a/latte-dock.desktop.template +++ b/po/desktop-templates/latte-dock.desktop.template @@ -1,7 +1,7 @@ [Desktop Entry] -_Name=Latte -_Comment=Dock for the masses -_GenericName=Dock +Name=Latte +Comment=Dock for the masses +GenericName=Dock Categories=Utility;X-SuSE-DesktopUtility; Exec=latte-dock %u @@ -10,4 +10,3 @@ InitialPreference=1 StartupNotify=true Terminal=false Type=Application - diff --git a/plasmoid.metadata.desktop.template b/po/desktop-templates/plasmoid.metadata.desktop.template similarity index 89% rename from plasmoid.metadata.desktop.template rename to po/desktop-templates/plasmoid.metadata.desktop.template index 6ab029e6e..eb7c1d75d 100644 --- a/plasmoid.metadata.desktop.template +++ b/po/desktop-templates/plasmoid.metadata.desktop.template @@ -1,7 +1,6 @@ [Desktop Entry] -_Name=Latte Plasmoid -_Comment=Plasmoid from the Latte Dock - +Name=Latte Plasmoid +Comment=Plasmoid from the Latte Dock Type=Service Icon=latte-dock @@ -18,6 +17,3 @@ X-KDE-PluginInfo-Category=Windows and Tasks X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-License=GPL v2+ X-KDE-PluginInfo-EnabledByDefault=true - - - diff --git a/shell.metadata.desktop.template b/po/desktop-templates/shell.metadata.desktop.template similarity index 84% rename from shell.metadata.desktop.template rename to po/desktop-templates/shell.metadata.desktop.template index 2b5e85107..70da2ce91 100644 --- a/shell.metadata.desktop.template +++ b/po/desktop-templates/shell.metadata.desktop.template @@ -1,7 +1,7 @@ [Desktop Entry] Encoding=UTF-8 -_Name=Latte Shell -_Comment=Shell provided for the Latte Dock +Name=Latte Shell +Comment=Shell provided for the Latte Dock Keywords=shell Type=Service diff --git a/po/update-metadata.sh b/po/update-metadata.sh old mode 100644 new mode 100755 index ae70eeafc..3ca9cc5f1 --- a/po/update-metadata.sh +++ b/po/update-metadata.sh @@ -1,26 +1,33 @@ #!/bin/sh -PROJECTPATHCONTAINMENT="../../containment" # containment path -PROJECTPATHPLASMOID="../../plasmoid" # plasmoid path -PROJECTPATHSHELL="../../shell" # shell path -PROJECTPATHAPP="../../app" # app path -BUGADDR="https://github.com/psifidotos/latte-dock/" # MSGID-Bugs +BASEDIR="$(pwd $(dirname $0))" # root of translatable sources +cd "$BASEDIR/.." -cd containment -intltool-merge --quiet --desktop-style . ../../containment.metadata.desktop.template "${PROJECTPATHCONTAINMENT}"/metadata.desktop.cmake -echo "metadata.desktop file for containment was updated..." +PROJECTCONTAINMENT="$(pwd)/containment/metadata.desktop.cmake" # containment path +PROJECTPLASMOID="$(pwd)/plasmoid/metadata.desktop.cmake" # plasmoid path +PROJECTSHELL="$(pwd)/shell/metadata.desktop.cmake" # shell path +PROJECTAPP="$(pwd)/app/latte-dock.desktop" # app path -cd ../plasmoid -intltool-merge --quiet --desktop-style . ../../plasmoid.metadata.desktop.template "${PROJECTPATHPLASMOID}"/metadata.desktop.cmake -echo "metadata.desktop file for plasmoid was updated..." +function generate_desktop_file +{ + cd "$BASEDIR/$1" -cd ../shell -intltool-merge --quiet --desktop-style . ../../shell.metadata.desktop.template "${PROJECTPATHSHELL}"/metadata.desktop.cmake -echo "metadata.desktop file for shell was updated..." + LINGUAS=$(ls *.po | xargs --no-run-if-empty --max-args=1 basename -s .po) + echo $LINGUAS > LINGUAS -cd ../app -intltool-merge --quiet --desktop-style . ../../latte-dock.desktop.template "${PROJECTPATHAPP}"/latte-dock.desktop -echo "latte-dock.desktop file for app was updated..." + # msgfmt first reads the ‘LINGUAS’ file under directory, + # and then processes all ‘.po’ files listed there + msgfmt --desktop --template="../desktop-templates/$2" -d . -o "$3" + rm "LINGUAS" + echo -e "metadata.desktop file for \e[0;32m$1\e[0m was updated..." +} +generate_desktop_file containment containment.metadata.desktop.template "$PROJECTCONTAINMENT" + +generate_desktop_file plasmoid plasmoid.metadata.desktop.template "$PROJECTPLASMOID" + +generate_desktop_file shell shell.metadata.desktop.template "$PROJECTSHELL" + +generate_desktop_file app latte-dock.desktop.template "$PROJECTAPP"