mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
fix(i18n): fix Russian layouts and the gaps the screenshot review found
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]>
This commit is contained in:
1 parent
3129e531e6
commit
2b6ccad732
71 files changed
+2435
-370
No files matched your search
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Recent Imagery text in the page's language: days, metres and the focused
|
||||
* day's readout. The model (`model.js`) stays English and i18n-free because AI
|
||||
* tool services import it outside the browser; this module is page-only.
|
||||
*/
|
||||
import { formatDate, formatRelativeTime, t } from '../../i18n/index.js';
|
||||
import { formatQuantity } from '../../ui/unitLabels.js';
|
||||
import { dayTime } from './model.js';
|
||||
|
||||
const SHORT_DAY = Object.freeze({
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
timeZone: 'UTC',
|
||||
});
|
||||
const LONG_DAY = Object.freeze({ ...SHORT_DAY, year: 'numeric' });
|
||||
|
||||
/** `Sep 18` / `18 сент.` for a `YYYY-MM-DD` day, in the page's language. */
|
||||
export function displayDay(day, options = SHORT_DAY) {
|
||||
const time = dayTime(day);
|
||||
return time === null ? '' : formatDate(time, options);
|
||||
}
|
||||
|
||||
/** `30 m` / `30 м`, number and unit kept together. */
|
||||
export const displayMetres = (value) => formatQuantity(value, 'm');
|
||||
|
||||
/** The readout's words in the page's language; the model keeps them English. */
|
||||
export const READOUT_WORDS = Object.freeze({
|
||||
date: (day) => displayDay(day, LONG_DAY),
|
||||
daysAgo: (delta) => formatRelativeTime(delta > 0 ? -delta : 0, 'day'),
|
||||
sensor: (sensor) => t(sensor),
|
||||
metres: displayMetres,
|
||||
overview: () => t('overview'),
|
||||
cloud: (cloud) => {
|
||||
if (!cloud) return t('cloud unknown');
|
||||
const min = Math.round(cloud.min);
|
||||
const max = Math.round(cloud.max);
|
||||
return min === max
|
||||
? t('{percent}% scene cloud', { percent: min })
|
||||
: t('{min}–{max}% scene cloud', { min, max });
|
||||
},
|
||||
});
|
||||
@@ -28,12 +28,12 @@ import {
|
||||
parseCandidateKey,
|
||||
quantizeBox,
|
||||
rankLatest,
|
||||
shortDay,
|
||||
utcDay,
|
||||
validateBox,
|
||||
viewTooLargeMessage,
|
||||
} from './model.js';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { msg, t } from '../../i18n/index.js';
|
||||
import { READOUT_WORDS, displayDay, displayMetres } from './display.js';
|
||||
|
||||
/**
|
||||
* Quiet time after the last arrow key before the focused day previews, so a
|
||||
@@ -48,9 +48,10 @@ export const SPLIT_PUBLISH_MS = 400;
|
||||
export const MODES = Object.freeze(['image', 'basemap', 'ab']);
|
||||
|
||||
const COMPARISON_IN_USE = 'Comparison in use by another scene';
|
||||
const COMPARISON_UNAVAILABLE = 'Esri map unavailable · no swipe';
|
||||
const COMPARISON_NEEDS_GLOBE = 'Swipe needs a globe map';
|
||||
const ESRI_KEPT = 'Imagery stays on Esri · CLEAR to use Google 3D';
|
||||
// Kept English in the snapshot (AI tools read it); the card translates them.
|
||||
const COMPARISON_UNAVAILABLE = msg('Esri map unavailable · no swipe');
|
||||
const COMPARISON_NEEDS_GLOBE = msg('Swipe needs a globe map');
|
||||
const ESRI_KEPT = msg('Imagery stays on Esri · CLEAR to use Google 3D');
|
||||
/** ZOOM IN's flight time, in seconds. */
|
||||
const ZOOM_FIT_SECONDS = 1.2;
|
||||
const DEFAULT_SPLIT = 0.5;
|
||||
@@ -774,7 +775,7 @@ export function createRecentImageryLayer({
|
||||
key: key || null,
|
||||
candidate: candidateFor(key),
|
||||
label: parsed
|
||||
? `${shortDay(parsed.day)} · ${t(PRODUCTS[parsed.product].name)} · ${PRODUCTS[parsed.product].resolutionM} m`
|
||||
? `${displayDay(parsed.day)} · ${t(PRODUCTS[parsed.product].name)} · ${displayMetres(PRODUCTS[parsed.product].resolutionM)}`
|
||||
: null,
|
||||
sourceOff,
|
||||
drapable: drapable(candidateFor(key)),
|
||||
@@ -1234,7 +1235,7 @@ export function createRecentImageryLayer({
|
||||
_alpha = 1;
|
||||
for (const slotId of SLOT_IDS) renderer.setAlpha(slotId, 1);
|
||||
}
|
||||
_notice = 'Box and images cleared';
|
||||
_notice = msg('Box and images cleared');
|
||||
syncRender();
|
||||
publish([...BOX_EDGES, 'a', 'b', 'split']);
|
||||
notify();
|
||||
@@ -1283,7 +1284,9 @@ export function createRecentImageryLayer({
|
||||
candidates,
|
||||
focusIndex,
|
||||
focus,
|
||||
readout: focus ? formatCandidateReadout(focus, now()) : '',
|
||||
readout: focus
|
||||
? formatCandidateReadout(focus, now(), READOUT_WORDS)
|
||||
: '',
|
||||
recommended: ranked.candidate
|
||||
? { key: ranked.candidate.key, reason: ranked.reason }
|
||||
: null,
|
||||
|
||||
@@ -228,7 +228,7 @@ test('a valid box searches and previews the START HERE day alone in IMAGE mode',
|
||||
assert.equal(snapshot.focus.key, S18, 'focus starts on it');
|
||||
assert.equal(snapshot.preview.key, S18);
|
||||
assert.equal(snapshot.preview.slot, 'a');
|
||||
assert.equal(snapshot.preview.label, 'Sep 18 · Sentinel-2 · 30 m');
|
||||
assert.equal(snapshot.preview.label, 'Sep 18 · Sentinel-2 · 30\u00a0m');
|
||||
assert.equal(snapshot.candidates[1].preview, true);
|
||||
const none = {
|
||||
key: null,
|
||||
|
||||
@@ -36,7 +36,7 @@ export const PRODUCTS = Object.freeze({
|
||||
label: 'HLS S30', // i18n-ignore: product code
|
||||
name: msg('Sentinel-2'),
|
||||
source: 'hls',
|
||||
sensor: 'Sentinel-2 via HLS',
|
||||
sensor: msg('Sentinel-2 via HLS'),
|
||||
resolutionM: 30,
|
||||
gibsLayer: 'HLS_S30_Nadir_BRDF_Adjusted_Reflectance',
|
||||
maxLevel: 12,
|
||||
@@ -48,7 +48,7 @@ export const PRODUCTS = Object.freeze({
|
||||
label: 'HLS L30', // i18n-ignore: product code
|
||||
name: msg('Landsat 8/9'),
|
||||
source: 'hls',
|
||||
sensor: 'Landsat 8/9 via HLS',
|
||||
sensor: msg('Landsat 8/9 via HLS'),
|
||||
resolutionM: 30,
|
||||
gibsLayer: 'HLS_L30_Nadir_BRDF_Adjusted_Reflectance',
|
||||
maxLevel: 12,
|
||||
@@ -266,6 +266,11 @@ export function utcDay(value) {
|
||||
: null;
|
||||
}
|
||||
|
||||
/** UTC midnight of a `YYYY-MM-DD` day in epoch ms, for locale formatting; null otherwise. */
|
||||
export function dayTime(day) {
|
||||
return isValidDay(day) ? Date.parse(`${day}T00:00:00Z`) : null;
|
||||
}
|
||||
|
||||
/** `Sep 18` for a `YYYY-MM-DD` day; '' otherwise. */
|
||||
export function shortDay(day) {
|
||||
const match = /^\d{4}-(\d{2})-(\d{2})$/.exec(String(day || ''));
|
||||
@@ -483,15 +488,14 @@ export function rankLatest(
|
||||
return { candidate: null, reason: null, certain };
|
||||
}
|
||||
|
||||
function daysAgoLabel(day, now) {
|
||||
/** Whole UTC days from `day` to the day of `now`; null when either is invalid. */
|
||||
function daysBetween(day, now) {
|
||||
const today = utcDay(now);
|
||||
if (!today) return null;
|
||||
const delta = Math.round(
|
||||
return Math.round(
|
||||
(Date.parse(`${today}T00:00:00Z`) - Date.parse(`${day}T00:00:00Z`)) /
|
||||
DAY_MS,
|
||||
);
|
||||
if (delta <= 0) return 'today';
|
||||
return delta === 1 ? 'yesterday' : `${delta} days ago`;
|
||||
}
|
||||
|
||||
function cloudLabel(cloud) {
|
||||
@@ -501,18 +505,40 @@ function cloudLabel(cloud) {
|
||||
return min === max ? `${min}% scene cloud` : `${min}–${max}% scene cloud`;
|
||||
}
|
||||
|
||||
/**
|
||||
* The words of the readout. The page passes its own (translated, locale
|
||||
* formatted) set; this module stays free of i18n because AI tool services
|
||||
* import it outside the browser.
|
||||
*/
|
||||
const READOUT_WORDS = Object.freeze({
|
||||
/** `Sep 18, 2026` for a valid `YYYY-MM-DD` day. */
|
||||
date: (day) => {
|
||||
const [y, m, d] = day.split('-').map(Number);
|
||||
return `${MONTHS[m - 1]} ${d}, ${y}`;
|
||||
},
|
||||
/** Age in whole UTC days, 0 or less for today. */
|
||||
daysAgo: (delta) =>
|
||||
delta <= 0 ? 'today' : delta === 1 ? 'yesterday' : `${delta} days ago`,
|
||||
sensor: (sensor) => sensor,
|
||||
metres: (value) => `${value} m`,
|
||||
overview: () => 'overview',
|
||||
/** `{ min, max }` scene cloud in percent, or null. */
|
||||
cloud: cloudLabel,
|
||||
});
|
||||
|
||||
/**
|
||||
* One-line UTC readout, e.g.
|
||||
* `Sep 18, 2026 17:12Z · 3 days ago · Sentinel-2 via HLS · 30 m · 12% scene cloud`.
|
||||
* @param {object} candidate
|
||||
* @param {string | number | Date} [now]
|
||||
* @param {Partial<typeof READOUT_WORDS>} [words] the page's localized words
|
||||
* @returns {string}
|
||||
*/
|
||||
export function formatCandidateReadout(candidate, now = new Date()) {
|
||||
export function formatCandidateReadout(candidate, now = new Date(), words) {
|
||||
const product = PRODUCTS[candidate?.product];
|
||||
if (!product || !candidate?.day) return '';
|
||||
const [y, m, d] = candidate.day.split('-').map(Number);
|
||||
let when = `${MONTHS[m - 1]} ${d}, ${y}`;
|
||||
if (!product || !isValidDay(candidate?.day)) return '';
|
||||
const say = words ? { ...READOUT_WORDS, ...words } : READOUT_WORDS;
|
||||
let when = say.date(candidate.day);
|
||||
if (candidate.timeRange?.start) {
|
||||
const start = hhmm(candidate.timeRange.start);
|
||||
const end = candidate.timeRange.end ? hhmm(candidate.timeRange.end) : start;
|
||||
@@ -522,11 +548,11 @@ export function formatCandidateReadout(candidate, now = new Date()) {
|
||||
: ` ${start}Z`;
|
||||
}
|
||||
const parts = [when];
|
||||
const ago = daysAgoLabel(candidate.day, now);
|
||||
if (ago) parts.push(ago);
|
||||
parts.push(product.sensor, `${product.resolutionM} m`);
|
||||
if (product.overview) parts.push('overview');
|
||||
parts.push(cloudLabel(candidate.cloud));
|
||||
const delta = daysBetween(candidate.day, now);
|
||||
if (delta !== null) parts.push(say.daysAgo(delta));
|
||||
parts.push(say.sensor(product.sensor), say.metres(product.resolutionM));
|
||||
if (product.overview) parts.push(say.overview());
|
||||
parts.push(say.cloud(candidate.cloud));
|
||||
return parts.join(' · ');
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user