mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 18:34:02 +00:00
A review of the Russian UI screenshots found ~90 places where longer words
broke the layout or text was still English. Fixed so they hold for any
language, then shortened where a control is short by design.
- Layout: label columns that size to their text (weather and wind settings,
Recent Imagery slots and opacity, style sliders, display panel), layer
list names and icons, buttons that wrap instead of overflowing (CCTV,
scenes, Bhote Koshi), voice header that always shows the cost, styled
EN | ES | RU chips, voice error tray above the dock.
- t() context: t('CLEAR', { context: 'action' }) is «СБРОСИТЬ» while the sky
stays «ЯСНО»; also used for radio categories, voice states and directions.
- Units and dates follow the locale through src/ui/unitLabels.js
(formatQuantity: localized number, translated unit, non-breaking space):
wind, pressure, cyclones, directions, CCTV, SDR gain, scene timing, flight
tooltip, Recent Imagery dates and resolution.
- Newly translated: directions turn-by-turn steps (built from the maneuver;
English matches the server word for word), HUD mode and summary, voice
card states, radio categories on the globe, CCTV status, layer source
lines, scene dialogs (Cancel, file pickers), Bhote Koshi statuses, titles,
comparison dates and caveat, Recent Imagery notices. Stored data and text
for AI tools stay English.
- es and ru: 1,885 messages each.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
import { formatNumber, msg, t } from '../i18n/index.js';
|
|
|
|
// Unit ids stay English in data, params and AI-tool readings; only the label
|
|
// shown on the page is translated. dBZ and °C read the same in every language.
|
|
const UNIT_LABELS = Object.freeze({
|
|
'km/h': msg('km/h'),
|
|
'm/s': msg('m/s'),
|
|
mph: msg('mph'),
|
|
hPa: msg('hPa'),
|
|
kt: msg('kt'),
|
|
kts: msg('kts'),
|
|
ft: msg('ft'),
|
|
km: msg('km'),
|
|
m: msg('m'),
|
|
h: msg('h'),
|
|
min: msg('min'),
|
|
s: msg('s'),
|
|
dB: msg('dB'),
|
|
});
|
|
|
|
/** The display label for a unit id; unknown units pass through unchanged. */
|
|
export function unitLabel(unit) {
|
|
return Object.hasOwn(UNIT_LABELS, unit) ? t(UNIT_LABELS[unit]) : unit || '';
|
|
}
|
|
|
|
/**
|
|
* A number and its unit that never break apart: "22,0 км/ч". Readings carry
|
|
* no digit grouping ("1008 hPa"), as on weather charts.
|
|
*/
|
|
export function formatQuantity(value, unit, options) {
|
|
const label = unitLabel(unit);
|
|
const number = formatNumber(value, { useGrouping: false, ...options });
|
|
return label ? `${number}\u00a0${label}` : number;
|
|
}
|
|
|
|
/**
|
|
* A legend stop such as "0.1", "-40" or "300+" in the active language.
|
|
* Anything that is not a plain number is shown as given.
|
|
*/
|
|
export function formatScaleLabel(label) {
|
|
const match = /^(-?\d+(?:\.\d+)?)(\+?)$/.exec(String(label ?? ''));
|
|
if (!match) return String(label ?? '');
|
|
const decimals = match[1].split('.')[1]?.length || 0;
|
|
return `${formatNumber(Number(match[1]), {
|
|
useGrouping: false,
|
|
minimumFractionDigits: decimals,
|
|
maximumFractionDigits: decimals,
|
|
})}${match[2]}`;
|
|
}
|