diff --git a/.tx/config b/.tx/config new file mode 100755 index 000000000..a698677d0 --- /dev/null +++ b/.tx/config @@ -0,0 +1,8 @@ +[main] +host = https://app.transifex.com + +[o:synonym:p:bitkit:r:stringsxml] +file_filter = app/src/main/res/values-/strings.xml +source_file = app/src/main/res/values/strings.xml +source_lang = en +type = ANDROID diff --git a/README.md b/README.md index e6e22ebfb..9a59caca6 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,28 @@ Reports are generated in: `app/build/reports/detekt/`. ``` ## Localization -See repo: https://github.com/synonymdev/bitkit-transifex-sync + +### Pulling Translations + +To pull the latest translations from Transifex: + +1. **Install Transifex CLI** (if not already installed): + - Follow the installation instructions: [Transifex CLI Installation](https://developers.transifex.com/docs/cli) + +2. **Authenticate with Transifex** (if not already configured): + - Create a `.transifexrc` file in your home directory (`~/.transifexrc`) with your API token: + ```ini + [https://www.transifex.com] + rest_hostname = https://rest.api.transifex.com + token = YOUR_API_TOKEN_HERE + ``` + - You can get your API token from your [Transifex account settings](https://www.transifex.com/user/settings/api/) + - The CLI will prompt you for an API token if one is not configured + +3. **Pull translations**: + ```sh + ./scripts/pull-translations.sh + ``` ## Build diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index bf3d14134..4b6d25ae1 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -1,6 +1,7 @@ نعم، احذف + جهات الاتصال اسمك اسمك اسم جهة الاتصال @@ -28,4 +29,4 @@ جهات الاتصال جهة الاتصال جهة الاتصال - \ No newline at end of file + diff --git a/app/src/main/res/values-b+es+419/strings.xml b/app/src/main/res/values-b+es+419/strings.xml index 00eb929cd..d680a4589 100644 --- a/app/src/main/res/values-b+es+419/strings.xml +++ b/app/src/main/res/values-b+es+419/strings.xml @@ -1121,4 +1121,4 @@ Tasa media actual Inclusión en siguiente bloque No se pudo consultar la condición actual de fees - \ No newline at end of file + diff --git a/app/src/main/res/values-ca/strings.xml b/app/src/main/res/values-ca/strings.xml index 583645cab..29d39ce40 100644 --- a/app/src/main/res/values-ca/strings.xml +++ b/app/src/main/res/values-ca/strings.xml @@ -614,4 +614,4 @@ Capçaleres de Bitcoin Blocs de Bitcoin Bitcoin Fets - \ No newline at end of file + diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 5d7244f6b..73ff7a668 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -1121,4 +1121,4 @@ Aktuální průměrný poplatek Zařazení do dalšího bloku Nepodařilo se získat aktuální poplatkovou úroveň - \ No newline at end of file + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 83678c3cc..e6993a57a 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -1099,4 +1099,4 @@ Wenn du es nicht eilig hast mit deiner Transaktion, könnte es besser sein etwas zu warten. Momentane Durchschnittsgebühr Konnte aktuelle Gebührenwetterlage nicht ermitteln. - \ No newline at end of file + diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 878aedaf5..2cb62a1d8 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -70,4 +70,4 @@ Προτάσεις Διαγραφή Προσαρμοσμένο - \ No newline at end of file + diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index f1f820de4..83e575821 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -1,5 +1,6 @@ + Copia de seguridad Saldo de gastos Comparta Bitkit Pagos instantáneos @@ -353,6 +354,7 @@ Utilizar código PIN Datos de Monedero Borrados Bitkit ha sido restaurado y todos los datos de monedero han sido borrados. + Ajustes Opciones de desarrollo activadas Opciones de desarrollo desactivadas General @@ -733,4 +735,4 @@ Titulares Bitcoin Bloques Bitcoin Hechos Bitcoin - \ No newline at end of file + diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 0d5f1e9bb..3277b27e8 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -32,6 +32,8 @@ Achetez des bitcoins Échec Veuillez réessayer + Soyez rémunéré + Lorsque Bitkit est fermé Suggestions Avancé Continue @@ -767,6 +769,10 @@ Réinitialiser Limite de l\'écart d\'adressage Mise à jour Les modifications prendront effet après le redémarrage de l\'application. + Voir en arrière + Voir en avant + Voir changement en arrière + Voir changement en avant URL du serveur Rapid-Gossip-Sync Connecter Mise à jour du serveur Rapid-Gossip-Sync @@ -1117,4 +1123,4 @@ Frais moyen actuel Inclusion dans le bloc suivant Impossible d’obtenir les frais de transaction actuels - \ No newline at end of file + diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 1a1b57d45..960fb640b 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -940,4 +940,4 @@ Titoli di Testa di Bitcoin Blocchi Bitcoin Fatti su Bitcoin - \ No newline at end of file + diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index b94046d7c..3df876e05 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -795,4 +795,4 @@ Bitcoin Nieuwes Bitcoin Blokken Bitcoin Feiten - \ No newline at end of file + diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 74391c714..533c87987 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -1121,4 +1121,4 @@ Obecna średnia opłata Włączenie do następnego bloku Nie udało się pobrać aktualnych danych o opłatach - \ No newline at end of file + diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 304ae2805..6e46f8ecb 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -1121,4 +1121,4 @@ Tarifa média atual Inclusão no próximo bloco Não foi possível obter o tempo atual da taxa - \ No newline at end of file + diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 2bb086017..d87dc7c4c 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -1011,4 +1011,4 @@ Биткоин Заголовки Биткоин Блоки Биткоин Факты - \ No newline at end of file + diff --git a/scripts/pull-translations.sh b/scripts/pull-translations.sh new file mode 100755 index 000000000..5b0e5a351 --- /dev/null +++ b/scripts/pull-translations.sh @@ -0,0 +1,224 @@ +#!/bin/bash + +# Script to pull translations from Transifex and clean up empty files/directories + +set -e + +# Validate script is run from project root +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" +RES_DIR="$PROJECT_ROOT/app/src/main/res" + +if [ ! -d "$RES_DIR" ]; then + echo "Error: Resource directory not found: $RES_DIR" + echo "Please run this script from the project root directory." + exit 1 +fi + +if [ ! -f "$PROJECT_ROOT/.tx/config" ]; then + echo "Error: Transifex config not found: $PROJECT_ROOT/.tx/config" + echo "Please ensure Transifex is configured for this project." + exit 1 +fi + +# Helper function to rename or merge directories +rename_or_merge() { + local src="$1" + local dst="$2" + local src_name=$(basename "$src") + local dst_name=$(basename "$dst") + local merge_errors=0 + + if [ ! -d "$src" ]; then + echo " Warning: Source directory does not exist: $src_name" + return 1 + fi + + if [ ! -d "$dst" ]; then + echo " Renaming: $src_name -> $dst_name" + if mv "$src" "$dst"; then + return 0 + else + echo " Error: Failed to rename $src_name to $dst_name" + return 1 + fi + else + echo " Merging: $src_name -> $dst_name" + while IFS= read -r -d '' item; do + if ! mv "$item" "$dst/" 2>/dev/null; then + echo " Warning: Failed to move $(basename "$item") from $src_name" + merge_errors=$((merge_errors + 1)) + fi + done < <(find "$src" -mindepth 1 -maxdepth 1 -print0 2>/dev/null) + + # Only remove source directory if merge was successful + if [ "$merge_errors" -eq 0 ]; then + if rmdir "$src" 2>/dev/null; then + return 0 + else + echo " Warning: Could not remove empty directory: $src_name" + return 1 + fi + else + echo " Error: Some files could not be merged from $src_name" + return 1 + fi + fi +} + +# Validate XML file is well-formed before processing +validate_xml() { + local file="$1" + # Basic validation: check for opening and closing resources tags + if ! grep -q '/dev/null || ! grep -q '' "$file" 2>/dev/null; then + echo " Warning: $file appears to be malformed XML, skipping normalization" + return 1 + fi + return 0 +} + +echo "Pulling translations from Transifex..." + +# Check if tx command is available +if ! command -v tx &> /dev/null; then + echo "Error: Transifex CLI (tx) is not installed or not in PATH" + echo "Please install it: https://developers.transifex.com/docs/cli" + exit 1 +fi + +# Run tx pull and check for errors +set +e # Temporarily disable exit on error to check tx pull status +tx pull -a +TX_EXIT_CODE=$? +set -e # Re-enable exit on error + +if [ "$TX_EXIT_CODE" -ne 0 ]; then + echo "Error: Transifex pull failed with exit code $TX_EXIT_CODE" + echo "Please check your Transifex configuration and authentication." + exit 1 +fi + +echo "" +echo "Renaming and cleaning up directories..." + +RENAMED_COUNT=0 +REMOVED_COUNT=0 + +# Process all values-* directories +while IFS= read -r dir; do + dir_name=$(basename "$dir") + dir_path=$(dirname "$dir") + + case "$dir_name" in + values-arb) + rename_or_merge "$dir" "$dir_path/values-ar" && RENAMED_COUNT=$((RENAMED_COUNT + 1)) + ;; + values-es_419) + rename_or_merge "$dir" "$dir_path/values-b+es+419" && RENAMED_COUNT=$((RENAMED_COUNT + 1)) + ;; + values-es_ES) + rename_or_merge "$dir" "$dir_path/values-es" && RENAMED_COUNT=$((RENAMED_COUNT + 1)) + ;; + values-b+es+419|values-es|values-pt) + # Keep these as-is + ;; + values-b+pt+PT|values-pt_PT) + echo " Removing: $dir_name" + rm -rf "$dir" && REMOVED_COUNT=$((REMOVED_COUNT + 1)) + ;; + values-b+pt+*|values-pt_*) + # Convert Brazilian Portuguese to values-pt + rename_or_merge "$dir" "$dir_path/values-pt" && RENAMED_COUNT=$((RENAMED_COUNT + 1)) + ;; + values-b+*) + # Convert other BCP 47 formats to underscore format + new_name=$(echo "$dir_name" | sed 's/values-b+\([a-z][a-z]*\)+\([A-Z0-9][A-Z0-9]*\)/values-\1_\2/') + if [ "$new_name" != "$dir_name" ]; then + rename_or_merge "$dir" "$dir_path/$new_name" && RENAMED_COUNT=$((RENAMED_COUNT + 1)) + fi + ;; + esac +done < <(find "$RES_DIR" -type d -name "values-*" 2>/dev/null | sort) + +echo " Renamed $RENAMED_COUNT directories" +echo " Removed $REMOVED_COUNT directories" + +echo "" +echo "Normalizing XML formatting..." + +# Normalize XML +NORMALIZED_COUNT=0 +while IFS= read -r file; do + # Validate XML before processing + if ! validate_xml "$file"; then + continue + fi + + if awk ' + { + gsub(/[[:space:]]+$/, "") + if ($0 ~ /^[[:space:]]*<\/resources>[[:space:]]*$/) { + print "" + saw_resources = 1 + next + } + if (saw_resources && $0 == "") next + if (saw_resources && $0 != "") saw_resources = 0 + print + } + ' "$file" > "$file.tmp"; then + if mv "$file.tmp" "$file" 2>/dev/null; then + NORMALIZED_COUNT=$((NORMALIZED_COUNT + 1)) + else + echo " Warning: Failed to replace $file" + rm -f "$file.tmp" + fi + else + echo " Warning: Failed to normalize $file" + rm -f "$file.tmp" + fi +done < <(find "$RES_DIR" -type f -path "*/values-*/strings.xml" 2>/dev/null) + +echo " Normalized $NORMALIZED_COUNT files" + +echo "" +echo "Cleaning up empty files and directories..." + +EMPTY_COUNT=0 +DELETED_DIRS=0 +declare -a dirs_to_check + +# Delete empty files and collect their directories +set +e # Allow commands to fail for empty file detection +while IFS= read -r file; do + line_count=$(wc -l < "$file" 2>/dev/null | tr -d ' ' || echo "0") + string_count=$(grep -c '/dev/null | wc -l | tr -d ' ') + set -e + if [ "$file_count" -eq 0 ]; then + echo " Deleting empty directory: $dir" + if rmdir "$dir" 2>/dev/null; then + DELETED_DIRS=$((DELETED_DIRS + 1)) + fi + fi +done + +echo "" +echo "Complete!" +echo " Renamed: $RENAMED_COUNT, Removed: $REMOVED_COUNT" +echo " Normalized: $NORMALIZED_COUNT" +echo " Deleted files: $EMPTY_COUNT, Deleted dirs: $DELETED_DIRS"