diff options
| author | Emīls <emils@mullvad.net> | 2025-11-20 11:29:17 +0100 |
|---|---|---|
| committer | Emīls <emils@mullvad.net> | 2025-11-20 11:29:17 +0100 |
| commit | 0b7747f64607f8f65e862135acf58118c6b4d29b (patch) | |
| tree | 45cd158f9a083e9fe8d210664ae6f21be8a83464 /scripts | |
| parent | 8beacc616749851c1e6d1fb18fc4a493f3c961f6 (diff) | |
| parent | 15ba64661b9ebb172c5baa3710b21105e611b805 (diff) | |
| download | mullvadvpn-bug-bash-2025-11-20.tar.xz mullvadvpn-bug-bash-2025-11-20.zip | |
Merge branch 'migrate-storekit2-calls-ios-1018' into bug-bash-2025-11-20bug-bash-2025-11-20
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/ios-localization | 78 | ||||
| -rwxr-xr-x | scripts/localization | 13 | ||||
| -rwxr-xr-x | scripts/utils/localization_utils | 9 |
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" +} |
