summaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/ios-localization78
-rwxr-xr-xscripts/localization13
-rwxr-xr-xscripts/utils/localization_utils9
3 files changed, 90 insertions, 10 deletions
diff --git a/scripts/ios-localization b/scripts/ios-localization
new file mode 100755
index 0000000000..6e83395d4a
--- /dev/null
+++ b/scripts/ios-localization
@@ -0,0 +1,78 @@
+#!/usr/bin/env bash
+
+set -eu
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+iOS_LOCALIZATION_DIR="$(cd "$SCRIPT_DIR/../ios/translation" && pwd)"
+cd "$SCRIPT_DIR"
+
+# shellcheck disable=SC1091
+source utils/log
+
+# shellcheck disable=SC1091
+source utils/localization_utils
+
+function main {
+ case ${1:-""} in
+ upload) upload_to_crowdin ;;
+ download) download_from_crowdin ;;
+ "")
+ echo "Available subcommands: upload and download"
+ ;;
+ *)
+ echo "Unknown parameter: $1"
+ exit 1
+ ;;
+ esac
+}
+
+function update_relay_locations {
+ log_header "Retrieving relay locations from server list and updating RelayLocationList.Swift"
+ pushd "$iOS_LOCALIZATION_DIR"
+ ./scripts/fetch-relay-locations.sh
+ ./scripts/relays-localization.sh
+ popd
+}
+
+function prepare_localization_strings {
+ update_relay_locations
+ update_ios_strings export
+ commit_changes "Export iOS strings"
+}
+
+function upload_to_crowdin {
+ ensure_crowdin_api_key
+ prepare_localization_strings
+ log_header "Uploading iOS translations to Crowdin"
+ pushd "$iOS_LOCALIZATION_DIR"
+ crowdin upload sources
+ crowdin upload translations
+ popd
+}
+
+function download_from_crowdin {
+ ensure_crowdin_api_key
+ log_header "Downloading iOS translations from Crowdin"
+ pushd "$iOS_LOCALIZATION_DIR"
+ crowdin download translations
+ popd
+ update_ios_strings import
+ commit_changes "Import iOS translations"
+}
+
+function update_ios_strings {
+ if [ $# -ne 1 ] || { [ "$1" != "export" ] && [ "$1" != "import" ]; }; then
+ echo "Usage: update_ios_strings [export|import]" >&2
+ return 2
+ fi
+ if [ "$1" = "export" ]; then
+ log_header "Extracting strings from iOS source code"
+ else
+ log_header "Updating strings into iOS source code with new translations"
+ fi
+ pushd "$iOS_LOCALIZATION_DIR"
+ ./scripts/localizations.sh "$1"
+ popd
+}
+
+main "$@"
diff --git a/scripts/localization b/scripts/localization
index 965ca0ff17..da05b455bc 100755
--- a/scripts/localization
+++ b/scripts/localization
@@ -8,6 +8,9 @@ cd "$SCRIPT_DIR"
# shellcheck disable=SC1091
source utils/log
+# shellcheck disable=SC1091
+source utils/localization_utils
+
function main {
case ${1:-""} in
prepare) prepare_localization_strings;;
@@ -50,12 +53,6 @@ function update_relay_locations_pot {
popd
}
-function commit_changes {
- if ! git diff-index --quiet HEAD --; then
- git commit -a -S -m "$1"
- fi
-}
-
function prepare_localization_strings {
sync_localizations
commit_changes "Update messages.pot"
@@ -64,10 +61,6 @@ function prepare_localization_strings {
commit_changes "Update relay-locations.pot"
}
-function ensure_crowdin_api_key {
- test ! -z "$CROWDIN_API_KEY"
-}
-
function upload_to_crowdin {
ensure_crowdin_api_key
diff --git a/scripts/utils/localization_utils b/scripts/utils/localization_utils
new file mode 100755
index 0000000000..ff4031edcb
--- /dev/null
+++ b/scripts/utils/localization_utils
@@ -0,0 +1,9 @@
+function commit_changes {
+ if ! git diff-index --quiet HEAD --; then
+ git commit -a -S -m "$1"
+ fi
+}
+
+function ensure_crowdin_api_key {
+ test ! -z "$CROWDIN_API_KEY"
+}