Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[main]
host = https://app.transifex.com

[o:synonym:p:bitkit:r:stringsxml]
file_filter = app/src/main/res/values-<lang>/strings.xml
source_file = app/src/main/res/values/strings.xml
source_lang = en
type = ANDROID
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="common__delete_yes">نعم، احذف</string>
<string name="settings__backup__category_contacts">جهات الاتصال</string>
<string name="slashtags__your_name">اسمك</string>
<string name="slashtags__your_name_capital">اسمك</string>
<string name="slashtags__contact_name">اسم جهة الاتصال</string>
Expand Down Expand Up @@ -28,4 +29,4 @@
<string name="wallet__drawer__contacts">جهات الاتصال</string>
<string name="wallet__recipient_contact">جهة الاتصال</string>
<string name="wallet__activity_contact">جهة الاتصال</string>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-b+es+419/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1121,4 +1121,4 @@
<string name="widgets__weather__current_fee">Tasa media actual</string>
<string name="widgets__weather__next_block">Inclusión en siguiente bloque</string>
<string name="widgets__weather__error">No se pudo consultar la condición actual de fees</string>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -614,4 +614,4 @@
<string name="widgets__news__name">Capçaleres de Bitcoin</string>
<string name="widgets__blocks__name">Blocs de Bitcoin</string>
<string name="widgets__facts__name">Bitcoin Fets</string>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1121,4 +1121,4 @@
<string name="widgets__weather__current_fee">Aktuální průměrný poplatek</string>
<string name="widgets__weather__next_block">Zařazení do dalšího bloku</string>
<string name="widgets__weather__error">Nepodařilo se získat aktuální poplatkovou úroveň</string>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1099,4 +1099,4 @@
<string name="widgets__weather__condition__poor__description">Wenn du es nicht eilig hast mit deiner Transaktion, könnte es besser sein etwas zu warten.</string>
<string name="widgets__weather__current_fee">Momentane Durchschnittsgebühr</string>
<string name="widgets__weather__error">Konnte aktuelle Gebührenwetterlage nicht ermitteln.</string>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@
<string name="slashtags__profile_link_suggestions">Προτάσεις</string>
<string name="slashtags__profile_delete">Διαγραφή</string>
<string name="widgets__widget__edit_custom">Προσαρμοσμένο</string>
</resources>
</resources>
4 changes: 3 additions & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="cards__backupSeedPhrase__title">Copia de seguridad</string>
<string name="cards__discount__description">Saldo de gastos</string>
<string name="cards__invite__description">Comparta Bitkit</string>
<string name="cards__lightning__description">Pagos instantáneos</string>
Expand Down Expand Up @@ -353,6 +354,7 @@
<string name="security__use_pin">Utilizar código PIN</string>
<string name="security__wiped_title">Datos de Monedero Borrados</string>
<string name="security__wiped_message">Bitkit ha sido restaurado y todos los datos de monedero han sido borrados.</string>
<string name="settings__settings">Ajustes</string>
<string name="settings__dev_enabled_title">Opciones de desarrollo activadas</string>
<string name="settings__dev_disabled_title">Opciones de desarrollo desactivadas</string>
<string name="settings__general_title">General</string>
Expand Down Expand Up @@ -733,4 +735,4 @@
<string name="widgets__news__name">Titulares Bitcoin</string>
<string name="widgets__blocks__name">Bloques Bitcoin</string>
<string name="widgets__facts__name">Hechos Bitcoin</string>
</resources>
</resources>
8 changes: 7 additions & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<string name="cards__buyBitcoin__description">Achetez des bitcoins</string>
<string name="cards__btFailed__title">Échec</string>
<string name="cards__btFailed__description">Veuillez réessayer</string>
<string name="cards__notifications__title">Soyez rémunéré</string>
<string name="cards__notifications__description">Lorsque Bitkit est fermé</string>
<string name="cards__suggestions">Suggestions</string>
<string name="common__advanced">Avancé</string>
<string name="common__continue">Continue</string>
Expand Down Expand Up @@ -767,6 +769,10 @@
<string name="settings__gap__reset">Réinitialiser</string>
<string name="settings__gap__gap_limit_update_title">Limite de l\'écart d\'adressage Mise à jour</string>
<string name="settings__gap__gap_limit_update_description">Les modifications prendront effet après le redémarrage de l\'application.</string>
<string name="settings__gap__look_behind">Voir en arrière</string>
<string name="settings__gap__look_ahead">Voir en avant</string>
<string name="settings__gap__look_behind_change">Voir changement en arrière</string>
<string name="settings__gap__look_ahead_change">Voir changement en avant</string>
<string name="settings__rgs__server_url">URL du serveur Rapid-Gossip-Sync</string>
<string name="settings__rgs__button_connect">Connecter</string>
<string name="settings__rgs__update_success_title">Mise à jour du serveur Rapid-Gossip-Sync</string>
Expand Down Expand Up @@ -1117,4 +1123,4 @@
<string name="widgets__weather__current_fee">Frais moyen actuel</string>
<string name="widgets__weather__next_block">Inclusion dans le bloc suivant</string>
<string name="widgets__weather__error">Impossible d’obtenir les frais de transaction actuels</string>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -940,4 +940,4 @@
<string name="widgets__news__name">Titoli di Testa di Bitcoin</string>
<string name="widgets__blocks__name">Blocchi Bitcoin</string>
<string name="widgets__facts__name">Fatti su Bitcoin</string>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -795,4 +795,4 @@
<string name="widgets__news__name">Bitcoin Nieuwes</string>
<string name="widgets__blocks__name">Bitcoin Blokken</string>
<string name="widgets__facts__name">Bitcoin Feiten</string>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1121,4 +1121,4 @@
<string name="widgets__weather__current_fee">Obecna średnia opłata</string>
<string name="widgets__weather__next_block">Włączenie do następnego bloku</string>
<string name="widgets__weather__error">Nie udało się pobrać aktualnych danych o opłatach</string>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1121,4 +1121,4 @@
<string name="widgets__weather__current_fee">Tarifa média atual</string>
<string name="widgets__weather__next_block">Inclusão no próximo bloco</string>
<string name="widgets__weather__error">Não foi possível obter o tempo atual da taxa</string>
</resources>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1011,4 +1011,4 @@
<string name="widgets__news__name">Биткоин Заголовки</string>
<string name="widgets__blocks__name">Биткоин Блоки</string>
<string name="widgets__facts__name">Биткоин Факты</string>
</resources>
</resources>
224 changes: 224 additions & 0 deletions scripts/pull-translations.sh
Original file line number Diff line number Diff line change
@@ -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 '<resources' "$file" 2>/dev/null || ! grep -q '</resources>' "$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 "</resources>"
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 '<string name=' "$file" 2>/dev/null || echo "0")

if [ "$line_count" -le 4 ] || [ "$string_count" -eq 0 ]; then
echo " Deleting empty file: $file"
dirs_to_check+=("$(dirname "$file")")
rm -f "$file"
EMPTY_COUNT=$((EMPTY_COUNT + 1))
fi
done < <(find "$RES_DIR" -type f -path "*/values-*/strings.xml" 2>/dev/null)
set -e

# Remove empty directories
for dir in $(printf '%s\n' "${dirs_to_check[@]}" | sort -u | sort -r); do
[ -d "$dir" ] || continue
set +e # Allow find to fail if directory is already gone
file_count=$(find "$dir" -type f ! -name '.gitkeep' ! -name '.DS_Store' 2>/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"
Loading