mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
i18n(ar): keep values whole in right-to-left text
Fixes from the Arabic screenshot review: - t() isolates every interpolated value in RTL locales (U+2068…U+2069), so a time (10/28 09:00 UTC), a code or an English name keeps its order inside an Arabic sentence; coordinates (30.326° ش) are isolated too. No-op in left-to-right languages. - The cockpit position readout reads right to left again now that its coordinates are isolated; gauges, tapes and roll counters stay LTR. - The start window's arrows point along the reading direction; FM seek and the glyph-only mini transport stay left to right, the worded PREV / PLAY / NEXT row follows the page; the Bhote Koshi clock stays a number. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
33985138ef
commit
4c3e366211
5 files changed
+49
-23
No files matched your search
+7
-3
@@ -81,9 +81,13 @@ const PLACEHOLDER_PATTERN = /\{([A-Za-z0-9_]+)\}/g;
|
||||
* stays visible instead of silently vanishing. */
|
||||
function interpolate(pattern, values) {
|
||||
if (!values) return pattern;
|
||||
return pattern.replace(PLACEHOLDER_PATTERN, (literal, name) =>
|
||||
Object.hasOwn(values, name) ? String(values[name]) : literal,
|
||||
);
|
||||
// In a right-to-left page each value is isolated: a time, a code or an
|
||||
// English name keeps its own order instead of mixing with the sentence.
|
||||
return pattern.replace(PLACEHOLDER_PATTERN, (literal, name) => {
|
||||
if (!Object.hasOwn(values, name)) return literal;
|
||||
const value = String(values[name]);
|
||||
return value === '' ? value : isolate(value);
|
||||
});
|
||||
}
|
||||
|
||||
/** A catalog string with something to show; an empty one counts as missing. */
|
||||
|
||||
Reference in new issue
Block a user