Skip to content

Commit 0c52d3f

Browse files
[Tooling] Localization README update (#795)
* Update README to reflect sync_localization lane and workflow update * Use same Buildkite annotation context on sync_localization lane * Add documentation about new localization PRs replacing the previous ones Co-authored-by: Olivier Halligon <[email protected]> * Expand documentation on automatic PO file upload Co-authored-by: Olivier Halligon <[email protected]> * Remove redundant description of automation steps * Add Mermaid graph of the localization workflow * Update README to clarify behavior when there's a previous localization PR Co-authored-by: Olivier Halligon <[email protected]> * Add descriptive info linked to the Mermaid chart * Change order to group workflow description sections --------- Co-authored-by: Olivier Halligon <[email protected]>
1 parent a48c1a8 commit 0c52d3f

File tree

2 files changed

+85
-11
lines changed

2 files changed

+85
-11
lines changed

fastlane/Fastfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ lane :sync_localization do
281281

282282
if is_ci
283283
buildkite_annotate(
284-
context: 'localization-sync-no-changes',
284+
context: 'localization-sync',
285285
style: 'info',
286286
message: 'No localization changes to commit. No PR was created.'
287287
)
@@ -317,7 +317,7 @@ lane :sync_localization do
317317

318318
if is_ci && pr_result
319319
buildkite_annotate(
320-
context: 'localization-sync-pr',
320+
context: 'localization-sync',
321321
style: 'info',
322322
message: "Localization Sync Pull Request: #{pr_result}"
323323
)

wp_localization/README.md

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,94 @@ _Note that we have to commit the `glotpress/en-US.pot` file here because that fi
1515

1616
## Workflow for Developers
1717

18-
### Automated Daily Sync
18+
### Automated Nightly Sync
1919

2020
The localization process runs automatically every night via a Buildkite pipeline (`.buildkite/nightly.yml`). This automated job:
2121

2222
1. **Generates the source en-US PO file** from `localization/en-US/main.ftl` and commits it to `glotpress/en-US.pot`
2323
2. **Downloads latest translations** from GlotPress for all supported locales as PO files
2424
3. **Converts downloaded PO files to Fluent format** and updates the corresponding `localization/*/main.ftl` files
25-
4. **Commits the updated translation files** to the repository
25+
4. **Creates a Pull Request** targeting `trunk` with the updated translation files and the updated original en-US PO file in the repository.
26+
- If a previous localization sync Pull Request was still open at the time the nightly sync happens, that previous Pull Request will be closed and a new one will be opened with the latest translations to take its place.
27+
28+
Once you merge the Pull Request into `trunk`, the updated `glotpress/en-US.pot` file will be picked up by a wpcom job to import it into GlotPress, so that translators can start working on the new strings.
2629

2730
This means that translation updates happen automatically without developer intervention.
2831

2932
### Adding New Localization Strings
3033

31-
1. **Add strings to the source file**: Edit `wp_localization/localization/en-US/main.ftl` to add or update localization strings.
32-
33-
2. **The automated nightly job will handle the rest**: The next nightly run will automatically:
34-
- Convert your changes to PO format (`glotpress/en-US.pot`)
35-
- Commit the updated source file
36-
- Upload to GlotPress via the wpcom cron job
34+
To add or update new localizable strings to the project, just edit `wp_localization/localization/en-US/main.ftl` to add or update them, using the English copy.
35+
36+
[The "Automated Nightly Sync" described above](#automated-nightly-sync) will take care of the rest. In particular:
37+
38+
* Once your `en-US/main.ftl` file has landed into `trunk`, it will be read by the "Automated Nightly Sync" job on its next run (2), to generate a `en-US.pot` file (which will later be imported in GlotPress (6 & 7))
39+
* That automation will also use the occasion to download latest translations from GlotPress (3), then create a Pull Request (4) containing both this generated `en-US.pot` from (2) and the new `*/main.ftl` translations from (3)
40+
* After you merge that Pull Request (5), the wpcom job will be able to later import the `en-US.pot` file with the latest originals to GlotPress (6 & 7)
41+
* Note that you'll only get the translations from the new string after 2 cycles of the Automated Nightly Sync: the first one (2–7) will ensure the new strings you added in (1) will make its way to GlotPress for translators to start working on it, while the 2nd run (9–14) will bring those translations from GlotPress to trunk after the translators had time to work on them.
42+
43+
## Localization Process Flow
44+
45+
Here's a visual representation of the typical localization workflow:
46+
47+
```mermaid
48+
sequenceDiagram
49+
autonumber
50+
actor Dev
51+
participant Git
52+
participant ANS as Automated Nightly Sync<br/>(Buildkite Job)
53+
participant GlotPress
54+
participant wpcom as wpcom cron job
55+
56+
Dev->>Git: Add new string "A" to `en-US/main.ftl` and commit to trunk
57+
58+
loop Nightly Sync (Run 1)
59+
activate ANS
60+
Git-->>ANS: Read `en-US/main.ftl` from trunk<br/>(existing strings + "A")
61+
note over ANS: Generate `en-US.pot` with all strings including "A"
62+
GlotPress-->>ANS: Download `.po` translations for existing strings
63+
note over ANS: Convert `.po` to `*/main.ftl` files
64+
ANS->>Git: Create Pull Request targeting trunk
65+
note right of Git: PR contains updated `en-US.pot` (with new string "A")<br/>and updated `*/main.ftl` files (existing translations only)
66+
deactivate ANS
67+
end
68+
69+
Dev->>Git: Merge Pull Request into trunk
70+
note right of Git: `en-US.pot` with string "A" now available
71+
72+
activate wpcom
73+
Git-->>wpcom: wpcom cron picks up updated `en-US.pot` from trunk
74+
wpcom->>GlotPress: Import new `en-US.pot` with string "A"
75+
deactivate wpcom
76+
77+
activate GlotPress
78+
note over GlotPress: Translators work on new string "A"
79+
deactivate GlotPress
80+
81+
Dev->>Git: Add new string "B" to `en-US/main.ftl` and commit to trunk
82+
83+
loop Nightly Sync (Run 2)
84+
activate ANS
85+
Git-->>ANS: Read `en-US/main.ftl` from trunk<br/>(existing + "A" + "B")
86+
note over ANS: Generate `en-US.pot` with all strings including "A" and "B"
87+
GlotPress-->>ANS: Download `.po` translations (now includes "A" translations)
88+
note over ANS: Convert `.po` to `*/main.ftl` files
89+
ANS->>Git: Create Pull Request targeting trunk
90+
note right of Git: PR contains updated `en-US.pot` (with new string "B")<br/>and updated `*/main.ftl` files (including "A" translations)
91+
deactivate ANS
92+
end
93+
94+
Dev->>Git: Merge Pull Request into trunk
95+
note right of Git: Translations for string "A" now in trunk
96+
97+
activate wpcom
98+
Git-->>wpcom: wpcom cron picks up updated `en-US.pot` from trunk
99+
wpcom->>GlotPress: Import new `en-US.pot` with string "B"
100+
deactivate wpcom
101+
102+
activate GlotPress
103+
note over GlotPress: Translators work on new string "B"
104+
deactivate GlotPress
105+
```
37106

38107
### Manual Operations (Optional)
39108

@@ -49,6 +118,11 @@ bundle exec fastlane generate_source_po_file
49118
bundle exec fastlane download_translations
50119
```
51120

121+
**Runs both lanes above and creates a new Pull Request with the changes targeting `trunk`:**
122+
```bash
123+
bundle exec fastlane sync_localization
124+
```
125+
52126
### Helper Lanes
53127

54128
- **`download_po_files_from_glotpress`**: Downloads PO files for all supported locales
@@ -58,5 +132,5 @@ bundle exec fastlane download_translations
58132

59133
- **Fluent format**: Uses [Project Fluent](https://projectfluent.org/) for localization files
60134
- **PO format**: Standard [gettext](https://www.gnu.org/software/gettext/manual/gettext.html) format used by GlotPress
61-
- **Conversion tool**: Uses the [fluent-tools](https://github.com/Automattic/fluent-rust-tools) Ruby gem for format conversion
135+
- **Conversion tool**: Uses the [fluent-tools](https://github.com/Automattic/fluent-rust-tools) CLI and Ruby Gem for format conversion
62136
- **GlotPress integration**: Downloads translations from `https://translate.wordpress.com/projects/mobile/wordpress-rs`

0 commit comments

Comments
 (0)