summaryrefslogtreecommitdiffhomepage
path: root/ios/translation/scripts/Readme.md
blob: 7350a53354fd502339e87da49dafa9c664e4429d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Localization Export Tool

Automate exporting localizable strings (XLIFF) from the MullvadVPN iOS project using `xcodebuild`.

This folder contains a Bash workflow that:

1. Builds the Xcode project (to emit/verify localized resources).
2. Exports and imports localizations for one or more languages.
3. Logs each failed run (timestamped) to a git‑ignored `logs/` directory.
4. Uses a throwaway build output directory (`build/`, also git‑ignored).
5. Cleans up Derived Data artifacts after export (configurable).

---

## Folder Structure

```
/mullvadvpn-app/ios/translation
├── locales
│   └── en.xliff
└── scripts
    ├── localizations.sh  # Main Bash script
    ├── build                    # Ephemeral DerivedData or build scratch dir (ignored)
    ├── logs                     # Timestamped run logs (ignored)
    └── README.md                # You're here

```

---

## Quick Start

```bash
cd ios/translation/scripts
chmod +x localizations.sh
./localizations.sh import   # To import localizations into code
./localizations.sh export   # To export localizations from code
```

By default the script uses values set near the top of the file (edit them before first run). You can override most settings via environment variables or CLI flags (see below).


## Multi‑Language Export

The script can loop languages. Set `EXPORT_LANGUAGES` to a comma‑separated list, e.g.:

> **Note:** In most cases, exporting only the base language for translation is sufficient.

```bash
EXPORT_LANGUAGES="da,de,en,es,fi,fr,it,ja,ko,my,nb,nl,pl,pt-PT,ru,sv,th,tr,zh-Hans,zh-Hant" ./localizations.sh export
```

XLIFF output will be placed under:

```
locales/
  en.xliff
  sv.xliff
  de.xliff
  fr.xliff
```

(Actual filenames depend on what `xcodebuild -exportLocalizations` emits.)

## Multi-Language Import
You can import translations back into code for multiple languages in one run.
Place your translated .xliff files in the locales/ folder, named by their language code:

```
locales/
  en.xliff
  sv.xliff
  de.xliff
  fr.xliff
```
Run the import command:

```bash
./localizations.sh import
```

---

## Logs

All stdout/stderr from each run is captured using `tee` into `logs/` with a timestamped filename, e.g.:

```
logs/
  build_20250723_142915.log
  build_20250724_094401.log
```