You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/i18n.md
+48-2Lines changed: 48 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Internationalization (i18n)
2
2
3
-
The `pup i18n` command can be used do fetch language files from a GlotPress instance for your project. To enable this
3
+
The `pup i18n` command can be used to fetch language files from a GlotPress instance for your project. To enable this
4
4
command, you must configure the `i18n` section of your `.puprc` file.
5
5
6
6
## The bare minimum
@@ -41,7 +41,53 @@ will download language files to an alternate location:
41
41
}
42
42
```
43
43
44
-
## All options
44
+
## Command-line options
45
+
46
+
You can adjust the retry and rate-limit handling behavior when running `pup i18n`:
47
+
48
+
| Option | Type | Default | Description |
49
+
|--------|------|---------|-------------|
50
+
|`--retries`|`int`|`3`| Number of retries per translation file on failure (minimum 1, maximum 10). Use this to control how aggressive retries should be. |
51
+
|`--delay`|`int`|`2`| Base delay in seconds between retries and for HTTP 429 rate-limit backoff (minimum 1). Increase this if you're hitting rate limits frequently. |
52
+
|`--batch-size`|`int`|`3`| Batch size for grouping downloads. Used for progress visibility and logging (minimum 1). This does not affect concurrency; downloads are sequential. |
53
+
|`--root`|`string`| — | Optional. Run the command from a different directory. |
54
+
55
+
### Rate-limit handling
56
+
57
+
When WordPress.org returns HTTP 429 (Too Many Requests), the `pup i18n` command handles it intelligently:
58
+
59
+
**Backoff strategy:**
60
+
- Uses exponential backoff with multipliers `[16, 31, 91, 151]` applied to the base `--delay`
61
+
- 1st 429: `delay × 16` (e.g., 2s × 16 = 32s)
62
+
- 2nd 429: `delay × 31` (e.g., 2s × 31 = 62s)
63
+
- 3rd 429: `delay × 91` (e.g., 2s × 91 = 182s)
64
+
- 4th 429: `delay × 151` (e.g., 2s × 151 = 302s)
65
+
- Additional 429s: Use the same multiplier as the 4th (capped at highest in the schedule)
66
+
67
+
**Server hints:**
68
+
- If the response includes a `Retry-After` header (numeric seconds), the command respects it BUT caps it at the computed backoff wait time
69
+
- Ensures we never wait longer than our backoff schedule allows
70
+
- If `Retry-After` is an HTTP-date format, it is ignored and the backoff schedule is used instead
71
+
72
+
**Retry consumption:**
73
+
- Each HTTP 429 consumes one retry attempt from `--retries`
74
+
- Non-429 failures (4xx/5xx errors, invalid responses) also consume retries and use the base `--delay`
75
+
- Once `--retries` are exhausted, the download fails for that translation file
76
+
77
+
**Example waits:**
78
+
- With `--delay=2 --retries=3`: Up to 3 attempts (0, 1, 2); if all are 429s: 32s + 62s + 182s = ~4.6 minutes total
79
+
- With `--delay=2 --retries=10`: Up to 10 attempts; if first 4 are 429s: 32s + 62s + 182s + 302s = ~9.6 minutes, then 5 more retries with base 2s delay
80
+
81
+
**Example commands:**
82
+
```bash
83
+
# Conservative: fewer retries, longer delay between attempts
84
+
pup i18n --retries=2 --delay=3
85
+
86
+
# Aggressive: more retries, shorter delay (use with caution on rate-limited APIs)
0 commit comments