summaryrefslogtreecommitdiffhomepage
path: root/gui/scripts
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2019-03-08 15:45:49 +0100
committerAndrej Mihajlov <and@mullvad.net>2019-03-08 15:45:49 +0100
commit1245828c33bbb91dfcccc875a532ea046f4f74d1 (patch)
tree0d18caaf661625442f17da342e814ca2988be680 /gui/scripts
parentd61d3b989ace19a74fe01673aff9e586f9f08132 (diff)
parent3e1b33666d97cec40264b48d825b02229788e437 (diff)
downloadmullvadvpn-1245828c33bbb91dfcccc875a532ea046f4f74d1.tar.xz
mullvadvpn-1245828c33bbb91dfcccc875a532ea046f4f74d1.zip
Merge branch 'add-crowdin-script'
Diffstat (limited to 'gui/scripts')
-rwxr-xr-xgui/scripts/crowdin.sh50
-rwxr-xr-xgui/scripts/update-translations.sh15
2 files changed, 55 insertions, 10 deletions
diff --git a/gui/scripts/crowdin.sh b/gui/scripts/crowdin.sh
new file mode 100755
index 0000000000..914007ac87
--- /dev/null
+++ b/gui/scripts/crowdin.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+set -e
+
+BASE_URL=https://api.crowdin.com/api/project/mullvad-app
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+ROOT_DIR=$( dirname $SCRIPT_DIR )
+LOCALE_DIR="$ROOT_DIR/locales"
+
+if [ $# -ne 1 ]; then
+ echo "Usage: $0 [upload|export|download]"
+ exit 1
+elif [ -z "$CROWDIN_API_KEY" ]; then
+ echo "Need to set environment variable CROWDIN_API_KEY"
+ exit 1
+fi
+
+mode=$1
+
+function upload_pot {
+ curl \
+ -F "files[/messages.pot]=@$LOCALE_DIR/messages.pot" \
+ $BASE_URL/update-file?key="$CROWDIN_API_KEY"
+}
+
+function export_translations {
+ curl \
+ $BASE_URL/export?key="$CROWDIN_API_KEY"
+}
+
+function download_translations {
+ wget \
+ --content-disposition \
+ $BASE_URL/download/all.zip?key="$CROWDIN_API_KEY"
+ unzip -o all.zip -d $LOCALE_DIR
+ find $LOCALE_DIR -type d -exec chmod 755 {} \;
+ find $LOCALE_DIR -type f -exec chmod 644 {} \;
+ rm all.zip
+}
+
+if [[ $mode == "upload" ]]; then
+ upload_pot
+elif [[ $mode == "export" ]]; then
+ export_translations
+elif [[ $mode == "download" ]]; then
+ download_translations
+else
+ echo "'$mode' is not a valid mode"
+ echo "Usage: $0 [upload|export|download]"
+ exit 1
+fi
diff --git a/gui/scripts/update-translations.sh b/gui/scripts/update-translations.sh
index 030d0c78a8..db9d5e7b74 100755
--- a/gui/scripts/update-translations.sh
+++ b/gui/scripts/update-translations.sh
@@ -3,23 +3,18 @@
# This script creates or updates the existing gettext catalogues using the POT template located
# under locales/messages.pot
-ROOT_DIR=$(dirname $(dirname "${BASH_SOURCE[0]}"))
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+ROOT_DIR=$( dirname $SCRIPT_DIR )
POT_FILE="$ROOT_DIR/locales/messages.pot"
for PO_FILE_DIR in $ROOT_DIR/locales/* ; do
if [ -d $PO_FILE_DIR ] ; then
- PO_FILE="$PO_FILE_DIR/messages.po"
- GITKEEP_FILE="$PO_FILE_DIR/.gitkeep"
+ LOCALE=$( basename $PO_FILE_DIR )
+ PO_FILE="$PO_FILE_DIR/messages-$LOCALE.po"
if [ -f $PO_FILE ] ; then
- echo "Update $PO_FILE_DIR\c"
+ echo "Update $PO_FILE"
msgmerge --no-fuzzy-matching --update $PO_FILE $POT_FILE
- else
- if [ -f $GITKEEP_FILE ] ; then
- echo "Remove $GITKEEP_FILE to initialize the new translation"
- else
- msginit --input $POT_FILE --output $PO_FILE --no-translator
- fi
fi
fi
done