Commit 812ca92
committed
fix(localizeText): accept { en: "" } as a valid translation (plan 61 S-E)
localizeText({ en: "" }) previously threw "textItems must have an
english translation" because `!textItem.en` is falsy for an empty
string. An empty string IS a valid translation (the author chose "no
text" for that locale); only a genuinely missing `en` should throw.
Switch the guard from `!textItem.en` to `textItem.en == null` so that:
- null / undefined still throw (unchanged contract)
- empty strings return as-is
- empty strings in non-`en` locales fall through to the next preference
via `!= null` check (was falsy check, which dropped empty strings)
New regression test [LOLY] pins the behaviour. The textItem with consent:
{ en: "" } shape that the Chat preset writes was poisoning peekInvite in
hds-webapp; the safeLocalize wrapper there can now be simplified.1 parent 269523d commit 812ca92
2 files changed
Lines changed: 20 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
125 | 137 | | |
126 | 138 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
40 | 45 | | |
41 | 46 | | |
42 | 47 | | |
43 | | - | |
| 48 | + | |
44 | 49 | | |
45 | | - | |
| 50 | + | |
| 51 | + | |
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
| |||
0 commit comments