From 5722b6bbdb2d7a311d15f577e6b46bcba3b4ac9f Mon Sep 17 00:00:00 2001 From: Adam Mills Date: Wed, 8 Nov 2017 23:59:10 -0500 Subject: [PATCH] Accept Lokalise token from environment (#598) --- script/translations_download | 8 +++++--- script/translations_upload_base | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/script/translations_download b/script/translations_download index 969ed6aea3..cfca3fefed 100755 --- a/script/translations_download +++ b/script/translations_download @@ -8,7 +8,7 @@ set -eu -o pipefail cd "$(dirname "$0")/.." -if [ ! -f .lokalise_token ] ; then +if [ -z "${LOKALISE_TOKEN-}" ] && [ ! -f .lokalise_token ] ; then echo "Lokalise API token is required to download the latest set of" \ "translations. Please create an account by using the following link:" \ "https://lokalise.co/signup/3420425759f6d6d241f598.13594006/all/" \ @@ -17,7 +17,9 @@ if [ ! -f .lokalise_token ] ; then exit 1 fi -API_TOKEN="$(<.lokalise_token)" +# Load token from file if not already in the environment +[ -z "${LOKALISE_TOKEN-}" ] && LOKALISE_TOKEN="$(<.lokalise_token)" + PROJECT_ID="3420425759f6d6d241f598.13594006" LOCAL_DIR="$(pwd)/translations" DOWNLOAD_FILE="${LOCAL_DIR}/Home_Assistant_-_Polymer_frontend-locale.zip" @@ -29,7 +31,7 @@ mkdir -p ${LOCAL_DIR} docker run \ -v ${LOCAL_DIR}:/opt/dest \ lokalise/lokalise-cli lokalise \ - --token ${API_TOKEN} \ + --token ${LOKALISE_TOKEN} \ export ${PROJECT_ID} \ --export_empty skip \ --type json \ diff --git a/script/translations_upload_base b/script/translations_upload_base index 613d102318..b896b266bc 100755 --- a/script/translations_upload_base +++ b/script/translations_upload_base @@ -8,7 +8,7 @@ set -eu -o pipefail cd "$(dirname "$0")/.." -if [ ! -f .lokalise_token ] ; then +if [ -z "${LOKALISE_TOKEN-}" ] && [ ! -f .lokalise_token ] ; then echo "Lokalise API token is required to download the latest set of" \ "translations. Please create an account by using the following link:" \ "https://lokalise.co/signup/3420425759f6d6d241f598.13594006/all/" \ @@ -17,7 +17,9 @@ if [ ! -f .lokalise_token ] ; then exit 1 fi -API_TOKEN="$(<.lokalise_token)" +# Load token from file if not already in the environment +[ -z "${LOKALISE_TOKEN-}" ] && LOKALISE_TOKEN="$(<.lokalise_token)" + PROJECT_ID="3420425759f6d6d241f598.13594006" LOCAL_FILE="$(pwd)/src/translations/en.json" LANG_ISO=en @@ -33,7 +35,7 @@ fi docker run \ -v ${LOCAL_FILE}:/opt/src/${LOCAL_FILE} \ lokalise/lokalise-cli lokalise \ - --token ${API_TOKEN} \ + --token ${LOKALISE_TOKEN} \ import ${PROJECT_ID} \ --file /opt/src/${LOCAL_FILE} \ --lang_iso ${LANG_ISO}