diff options
-rw-r--r-- | asteroid-stopwatch.desktop | 19 | ||||
-rw-r--r-- | asteroid-stopwatch.desktop.template | 7 | ||||
-rw-r--r-- | asteroid-stopwatch.pro | 20 | ||||
-rw-r--r-- | i18n/asteroid-stopwatch.de.ts | 12 | ||||
-rw-r--r-- | i18n/asteroid-stopwatch.desktop.h | 5 | ||||
-rw-r--r-- | i18n/asteroid-stopwatch.es.ts | 12 | ||||
-rw-r--r-- | i18n/asteroid-stopwatch.fa.ts | 12 | ||||
-rw-r--r-- | i18n/asteroid-stopwatch.fr.ts | 12 | ||||
-rw-r--r-- | i18n/asteroid-stopwatch.ko.ts | 12 | ||||
-rw-r--r-- | i18n/asteroid-stopwatch.nl.ts | 12 | ||||
-rw-r--r-- | i18n/asteroid-stopwatch.pl.ts | 12 | ||||
-rw-r--r-- | i18n/asteroid-stopwatch.pt_BR.ts | 12 | ||||
-rw-r--r-- | i18n/asteroid-stopwatch.ru.ts | 12 | ||||
-rw-r--r-- | i18n/asteroid-stopwatch.sv.ts | 12 | ||||
-rw-r--r-- | i18n/asteroid-stopwatch.uk.ts | 12 | ||||
-rwxr-xr-x | i18n/generate-desktop.sh | 61 |
16 files changed, 224 insertions, 20 deletions
diff --git a/asteroid-stopwatch.desktop b/asteroid-stopwatch.desktop deleted file mode 100644 index f6f0edf..0000000 --- a/asteroid-stopwatch.desktop +++ /dev/null @@ -1,19 +0,0 @@ -[Desktop Entry] -Type=Application -Name=Stopwatch -Name[de_DE]=Stoppuhr -Name[es]=Cronometro -Name[fa]=کرونومتر -Name[fr]=Chronomètre -Name[ko]=초시계 -Name[nl_NL]=Stopwatch -Name[pl]=Stoper -Name[pt_BR]=Cronômetro -Name[ru]=секундомер -Name[sv]=Tidtagarur -Name[uk]=Секундомір -Categories=Applications; -Exec=invoker --single-instance --type=qtcomponents-qt5 /usr/bin/asteroid-stopwatch -Icon=ios-stopwatch-outline -X-Asteroid-Center-Color=#b01c7e -X-Asteroid-Outer-Color=#420a2f diff --git a/asteroid-stopwatch.desktop.template b/asteroid-stopwatch.desktop.template new file mode 100644 index 0000000..8c2ba37 --- /dev/null +++ b/asteroid-stopwatch.desktop.template @@ -0,0 +1,7 @@ +[Desktop Entry] +Type=Application +Categories=Applications; +Exec=invoker --single-instance --type=qtcomponents-qt5 /usr/bin/asteroid-stopwatch +Icon=ios-stopwatch-outline +X-Asteroid-Center-Color=#b01c7e +X-Asteroid-Outer-Color=#420a2f diff --git a/asteroid-stopwatch.pro b/asteroid-stopwatch.pro index a9730b0..b3c7850 100644 --- a/asteroid-stopwatch.pro +++ b/asteroid-stopwatch.pro @@ -7,10 +7,28 @@ SOURCES += main.cpp RESOURCES += resources.qrc OTHER_FILES += main.qml +lupdate_only{ + SOURCES = i18n/asteroid-stopwatch.desktop.h +} + +# Needed for lupdate +TRANSLATIONS = i18n/asteroid-stopwatch.de.ts \ + i18n/asteroid-stopwatch.es.ts \ + i18n/asteroid-stopwatch.fa.ts \ + i18n/asteroid-stopwatch.fr.ts \ + i18n/asteroid-stopwatch.ko.ts \ + i18n/asteroid-stopwatch.nl.ts \ + i18n/asteroid-stopwatch.pl.ts \ + i18n/asteroid-stopwatch.pt_BR.ts \ + i18n/asteroid-stopwatch.ru.ts \ + i18n/asteroid-stopwatch.sv.ts \ + i18n/asteroid-stopwatch.uk.ts + TARGET = asteroid-stopwatch target.path = /usr/bin/ -desktop.files = asteroid-stopwatch.desktop +desktop.commands = bash $$PWD/i18n/generate-desktop.sh $$PWD asteroid-stopwatch.desktop +desktop.files = $$OUT_PWD/asteroid-stopwatch.desktop desktop.path = /usr/share/applications INSTALLS += target desktop diff --git a/i18n/asteroid-stopwatch.de.ts b/i18n/asteroid-stopwatch.de.ts new file mode 100644 index 0000000..d6bc113 --- /dev/null +++ b/i18n/asteroid-stopwatch.de.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="de_DE"> +<context> + <name>QObject</name> + <message> + <location filename="asteroid-stopwatch.desktop.h" line="5"/> + <source>Stopwatch</source> + <translation>Stoppuhr</translation> + </message> +</context> +</TS> diff --git a/i18n/asteroid-stopwatch.desktop.h b/i18n/asteroid-stopwatch.desktop.h new file mode 100644 index 0000000..8f642d6 --- /dev/null +++ b/i18n/asteroid-stopwatch.desktop.h @@ -0,0 +1,5 @@ +/* This dummy header is just used to generate a translatable Qt string that + * will be integrated to i18n/.ts files, translated on Weblate and then merged + * back with the .desktop.template file into a single .desktop file. */ + +QObject::tr("Stopwatch"); diff --git a/i18n/asteroid-stopwatch.es.ts b/i18n/asteroid-stopwatch.es.ts new file mode 100644 index 0000000..d2aac15 --- /dev/null +++ b/i18n/asteroid-stopwatch.es.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="es_ES"> +<context> + <name>QObject</name> + <message> + <location filename="asteroid-stopwatch.desktop.h" line="5"/> + <source>Stopwatch</source> + <translation>Cronometro</translation> + </message> +</context> +</TS> diff --git a/i18n/asteroid-stopwatch.fa.ts b/i18n/asteroid-stopwatch.fa.ts new file mode 100644 index 0000000..708781b --- /dev/null +++ b/i18n/asteroid-stopwatch.fa.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="fa_IR"> +<context> + <name>QObject</name> + <message> + <location filename="asteroid-stopwatch.desktop.h" line="5"/> + <source>Stopwatch</source> + <translation>کﺭﻮﻧﻮﻤﺗﺭ</translation> + </message> +</context> +</TS> diff --git a/i18n/asteroid-stopwatch.fr.ts b/i18n/asteroid-stopwatch.fr.ts new file mode 100644 index 0000000..14ba06e --- /dev/null +++ b/i18n/asteroid-stopwatch.fr.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="fr_FR"> +<context> + <name>QObject</name> + <message> + <location filename="asteroid-stopwatch.desktop.h" line="5"/> + <source>Stopwatch</source> + <translation>Chronomètre</translation> + </message> +</context> +</TS> diff --git a/i18n/asteroid-stopwatch.ko.ts b/i18n/asteroid-stopwatch.ko.ts new file mode 100644 index 0000000..2d682b9 --- /dev/null +++ b/i18n/asteroid-stopwatch.ko.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="ko_KR"> +<context> + <name>QObject</name> + <message> + <location filename="asteroid-stopwatch.desktop.h" line="5"/> + <source>Stopwatch</source> + <translation>초시계</translation> + </message> +</context> +</TS> diff --git a/i18n/asteroid-stopwatch.nl.ts b/i18n/asteroid-stopwatch.nl.ts new file mode 100644 index 0000000..6a0379c --- /dev/null +++ b/i18n/asteroid-stopwatch.nl.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="nl_NL"> +<context> + <name>QObject</name> + <message> + <location filename="asteroid-stopwatch.desktop.h" line="5"/> + <source>Stopwatch</source> + <translation>Stopwatch</translation> + </message> +</context> +</TS> diff --git a/i18n/asteroid-stopwatch.pl.ts b/i18n/asteroid-stopwatch.pl.ts new file mode 100644 index 0000000..5690963 --- /dev/null +++ b/i18n/asteroid-stopwatch.pl.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="pl_PL"> +<context> + <name>QObject</name> + <message> + <location filename="asteroid-stopwatch.desktop.h" line="5"/> + <source>Stopwatch</source> + <translation>Stoper</translation> + </message> +</context> +</TS> diff --git a/i18n/asteroid-stopwatch.pt_BR.ts b/i18n/asteroid-stopwatch.pt_BR.ts new file mode 100644 index 0000000..3e38b75 --- /dev/null +++ b/i18n/asteroid-stopwatch.pt_BR.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="pt_BR"> +<context> + <name>QObject</name> + <message> + <location filename="asteroid-stopwatch.desktop.h" line="5"/> + <source>Stopwatch</source> + <translation>Cronômetro</translation> + </message> +</context> +</TS> diff --git a/i18n/asteroid-stopwatch.ru.ts b/i18n/asteroid-stopwatch.ru.ts new file mode 100644 index 0000000..7025f1d --- /dev/null +++ b/i18n/asteroid-stopwatch.ru.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="ru_RU"> +<context> + <name>QObject</name> + <message> + <location filename="asteroid-stopwatch.desktop.h" line="5"/> + <source>Stopwatch</source> + <translation>секундомер</translation> + </message> +</context> +</TS> diff --git a/i18n/asteroid-stopwatch.sv.ts b/i18n/asteroid-stopwatch.sv.ts new file mode 100644 index 0000000..787f727 --- /dev/null +++ b/i18n/asteroid-stopwatch.sv.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="sv_SE"> +<context> + <name>QObject</name> + <message> + <location filename="asteroid-stopwatch.desktop.h" line="5"/> + <source>Stopwatch</source> + <translation>Tidtagarur</translation> + </message> +</context> +</TS> diff --git a/i18n/asteroid-stopwatch.uk.ts b/i18n/asteroid-stopwatch.uk.ts new file mode 100644 index 0000000..bffce44 --- /dev/null +++ b/i18n/asteroid-stopwatch.uk.ts @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="uk_UA"> +<context> + <name>QObject</name> + <message> + <location filename="asteroid-stopwatch.desktop.h" line="5"/> + <source>Stopwatch</source> + <translation>Секундомір</translation> + </message> +</context> +</TS> diff --git a/i18n/generate-desktop.sh b/i18n/generate-desktop.sh new file mode 100755 index 0000000..f4c8a3e --- /dev/null +++ b/i18n/generate-desktop.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# This script is used to extract the translated app names found inevery .ts file +# and gather those strings with the .desktop.template file in a single .desktop + +if [ "$#" -ne 2 ]; then + echo "usage: $0 src_directory output.desktop" + exit 1 +fi + +SRC_DIR=$1 +OUTPUT_DESKTOP_FILE=$2 +if [ ! -f "${SRC_DIR}/${OUTPUT_DESKTOP_FILE}.template" ]; then + echo "${SRC_DIR}/${OUTPUT_DESKTOP_FILE}.template not found" + exit 2 +fi +if [ ! -f "${SRC_DIR}/i18n/${OUTPUT_DESKTOP_FILE}.h" ]; then + echo "${SRC_DIR}/i18n/${OUTPUT_DESKTOP_FILE}.h not found" + exit 2 +fi + +DEFAULT_NAME=`grep -oP 'QObject::tr\("\K[^"]+(?="\);)' ${SRC_DIR}/i18n/${OUTPUT_DESKTOP_FILE}.h` +if [ -z "$DEFAULT_NAME" ]; then + echo "Default name can not be found in ${SRC_DIR}/i18n/${OUTPUT_DESKTOP_FILE}.h" + exit 3 +fi + +cat ${SRC_DIR}/${OUTPUT_DESKTOP_FILE}.template > ${OUTPUT_DESKTOP_FILE} +echo "Name=$DEFAULT_NAME" >> $OUTPUT_DESKTOP_FILE + +for FILE in ${SRC_DIR}/i18n/*.ts; do + echo "Processing $FILE..." + + PROCESSED_LANG=`grep -oP 'language="\K[^"]+(?=")' $FILE` + if [ -z "$PROCESSED_LANG" ]; then + echo "> Couldn't find a corresponding language id, aborting" + continue + fi + echo "> Language: $PROCESSED_LANG detected" + + TRANSLATION_LINE=`grep -A 2 '<location.*desktop\.h" ' $FILE | grep '<translation'` + if [ -z "$TRANSLATION_LINE" ]; then + echo "> Couldn't find a corresponding desktop.h translation, aborting" + continue + fi + + LINE_IS_UNFINISHED=`echo $TRANSLATION_LINE | grep unfinished` + if [ ! -z "$LINE_IS_UNFINISHED" ]; then + echo "> Translation line has been found but is marked as unfinished, aborting" + continue + fi + + TRANSLATED_NAME=`echo $TRANSLATION_LINE | grep -oP '>\K[^<]*(?=</translation>)'` + if [ -z "$TRANSLATED_NAME" ]; then + echo "> Translation is empty, aborting" + continue + fi + echo "> Translation '$TRANSLATED_NAME' found, filling $OUTPUT_DESKTOP_FILE" + + echo "Name[$PROCESSED_LANG]=$TRANSLATED_NAME" >> $OUTPUT_DESKTOP_FILE +done |