i18n: plural forms and contexts the catalogs could only work around

The last translation review left four kinds of problem it could only
reword around in the catalogs. They are fixed in the code now, and the
catalogs go back to natural wording.

- Counts shown with plain t() are tn() plurals: the wildlife count, the
  Data Library "Showing {shown} of {total}", the News time window (which
  offers 1 h) and the GhostMaps event age (which offers 1 day). The
  English keys stay; the catalogs get real forms, as in "Última 1 h" and
  "Últimas 24 h", or "1 Tag" and "7 Tage".
- The bridge radar range and ring spacing are tn() plurals too. The
  spacing is fractional at the short ranges, and Intl.PluralRules gives
  0.75 and 1.5 their own form: ru "0,75 МОР. МИЛИ", "12 МОР. МИЛЬ".
- Street level no longer passes "the view centre" or "this spot" as
  {place}: each case has a message of its own, so a preposition no
  longer meets a phrase in the wrong case. The progress line had the
  same leak and showed the English phrase.
- Latest, FOCUS, CONFIRMED and "{label} · COURSE {heading}°" are split
  with a context where one key served two places: the News heading, the
  orbital site status, the Wildlife chip and a ship's course.

"CURRENTLY OVER" ended in a preposition that a country name in the
nominative cannot follow in uk, de, it and pt. It reads "under the
satellite" there now, as ru already did.

I18N.md gains the two rules behind these fixes.
This commit is contained in:
German Khokhlov committed 2026-11-13 18:50:34 +04:00
1 parent 42540ad85e
commit 209b135ff1
37 files changed
+1124 -196

No files matched your search

+7 -4
View File
@@ -762,9 +762,12 @@ export function createGhostMapsLayer({
title:
days === null
? t('Show markers of every age')
: t('Maximum event age: {days}d; undated markers are kept', {
days: formatNumber(days),
}),
: tn(
days,
'Maximum event age: {days}d; undated markers are kept',
'Maximum event age: {days}d; undated markers are kept',
{ days: formatNumber(days) },
),
active: days === _ageDays,
onClick: () => setAgeDays(days),
})),
@@ -799,7 +802,7 @@ export function createGhostMapsLayer({
};
}),
legend: [],
info: `${_ageDays === null ? t('All markers') : t('Event age: {days}d · undated kept', { days: formatNumber(_ageDays) })} · ${info}`,
info: `${_ageDays === null ? t('All markers') : tn(_ageDays, 'Event age: {days}d · undated kept', 'Event age: {days}d · undated kept', { days: formatNumber(_ageDays) })} · ${info}`,
infoTitle: t(
'S2 Underground publishes these KMZ products to GitHub. New uploads are detected within seconds and replace the previous edition automatically. Click a marker for its report.',
),
+30
View File
@@ -1,6 +1,7 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import * as Cesium from 'cesium';
import { setLocale } from '../../i18n/index.js';
import { createGhostMapsLayer } from './index.js';
import { GHOSTMAPS_PRODUCTS, GHOSTMAPS_LATEST_DROP } from './catalog.js';
@@ -248,6 +249,35 @@ test('age controls default to seven days and widening restores filtered and expi
assert.equal(ageChip(layer, null).active, true);
});
test('the event age agrees with its number of days', async (t) => {
t.after(() => setLocale('en'));
const { layer, viewer } = fixture(t, { reports: [{ name: 'Undated' }] });
await layer.update(viewer);
const info = () =>
layer.getRowControls().info.split(' · ').slice(0, 2).join(' · ');
assert.equal(
ageChip(layer, 1).title,
'Maximum event age: 1d; undated markers are kept',
);
setLocale('de');
assert.equal(
ageChip(layer, 1).title,
'Maximales Ereignisalter: 1 Tag; undatierte Markierungen bleiben erhalten',
);
assert.equal(
ageChip(layer, 7).title,
'Maximales Ereignisalter: 7 Tage; undatierte Markierungen bleiben erhalten',
);
assert.equal(info(), 'Ereignisalter: 7 Tage · undatierte bleiben');
await ageChip(layer, 1).onClick();
assert.equal(info(), 'Ereignisalter: 1 Tag · undatierte bleiben');
setLocale('es');
assert.equal(
info(),
'Antigüedad: 1 día · se conservan los marcadores sin fecha',
);
});
test('age preferences persist independently of product choices and reject invalid storage', async (t) => {
const values = new Map([['gev.ghostmaps.products', '["cip"]']]);
const storage = {
@@ -69,3 +69,38 @@ test('the mission panel translates only the fallback status', (t) => {
assert.equal(shownStatus(UNKNOWN_LAUNCH_STATUS), 'Desconocido');
assert.equal(shownStatus('Launch Successful'), 'Launch Successful');
});
test('a confirmed landing position is worded apart from the CONFIRMED sightings chip', (t) => {
t.after(() => setLocale('en'));
const position = () =>
createPanel({
state: {
_selectedLaunchId: 'mission-1',
_launches: [
{
id: 'mission-1',
name: 'Example',
status: 'Launch Successful',
payloads: [],
recoveryStages: [
{
name: 'B1080',
endpoint: { lat: 28.41, lon: -80.6, accuracy: 'CONFIRMED' },
},
],
},
],
_replayTracks: new Map(),
},
parts: {
overlays: { shortMissionLabel: (name) => name },
policyHelpers: { missionPathPresentation: () => ({}) },
replay: { presentReplay: () => ({}) },
},
}).presentMission().stages[0].position;
assert.match(position(), / · CONFIRMED$/);
// One landing, singular: sv BEKRÄFTAD, where the sightings chip says
// BEKRÄFTADE.
setLocale('sv');
assert.match(position(), / · BEKRÄFTAD$/);
});
@@ -542,7 +542,7 @@ test('retention never revives an incumbent card after the observation window exp
test('all heights and the sampled fallback use the same sightings-in-view count label', () => {
const h = harness();
h.state.renderedRows = [sighting];
assert.equal(h.layer.getStats().countLabel, '1 sightings in view');
assert.equal(h.layer.getStats().countLabel, '1 sighting in view');
h.state.sightingCount = 2000;
assert.equal(h.layer.getStats().count, 2000);
assert.equal(
@@ -560,6 +560,32 @@ test('all heights and the sampled fallback use the same sightings-in-view count
}
});
test('the sightings count takes the plural form of its number', (t) => {
t.after(() => setLocale('en'));
const h = harness();
const label = (count) => {
h.state.sightingCount = count;
return h.layer.getStats().countLabel;
};
setLocale('ru');
assert.equal(label(1), '1 наблюдение в кадре');
assert.equal(label(3), '3 наблюдения в кадре');
assert.equal(label(5), '5 наблюдений в кадре');
setLocale('de');
assert.equal(label(1), '1 Beobachtung im Bild');
assert.equal(label(2000), '2.000 Beobachtungen im Bild');
});
test('the CONFIRMED chip names the sightings, apart from a confirmed launch landing', (t) => {
t.after(() => setLocale('en'));
const h = harness();
assert.equal(h.chip('quality-confirmed').label, 'CONFIRMED');
setLocale('sv');
assert.equal(h.chip('quality-confirmed').label, 'BEKRÄFTADE');
setLocale('es');
assert.equal(h.chip('quality-confirmed').label, 'CONFIRMADAS');
});
test('a stale fallback with a failed-refresh deadline remains DEGRADED, retryable and dated to the cached data', async () => {
const h = harness({
getSnapshotDetail: async () => ({
+9 -5
View File
@@ -1,4 +1,4 @@
import { t, formatNumber, translateKnown } from '../../i18n/index.js';
import { t, tn, formatNumber, translateKnown } from '../../i18n/index.js';
import { msg } from '../../i18n/marker.js';
import { translateFeedError } from '../../ui/statusText.js';
import { wildlifeIconicGroup } from './model.js';
@@ -137,7 +137,8 @@ export function createControls({ state, services, parts }) {
const chips = [
chip({
id: WILDLIFE_CONFIRMED_CHIP_ID,
label: t('CONFIRMED'),
// The sightings, plural; a launch landing is CONFIRMED alone.
label: t('CONFIRMED', { context: 'sightings filter' }),
title: t('Show only community-confirmed (research-grade) sightings'),
params: {
confirmed: confirmedFailed ? state.confirmed : !state.confirmed,
@@ -214,9 +215,12 @@ export function createControls({ state, services, parts }) {
stale: state.stale,
loading,
refreshing,
countLabel: t('{count} sightings in view', {
count: formatNumber(count),
}),
countLabel: tn(
count,
'{count} sighting in view',
'{count} sightings in view',
{ count: formatNumber(count) },
),
loadingLabel: loading
? t('loading...')
: refreshing
@@ -1987,7 +1987,7 @@ test('unavailable grids fail closed to visible sampled sprites without a global
assert.equal(h.clicks.collection.values[0].id, 'wildlife:inat:1');
assert.ok(h.clicks.collection.values[0].width * 0.5 >= 8);
assert.equal(h.layer.getStats().count, 1);
assert.match(h.layer.getStats().countLabel, /sightings in view/);
assert.equal(h.layer.getStats().countLabel, '1 sighting in view');
assert.equal(h.layer.getStats().partial, undefined);
assert.equal(layerFeedState(h.layer.getStats()), 'degraded');
assert.match(h.layer.getStats().error, /Malformed iNaturalist grid response/);
@@ -2024,7 +2024,7 @@ test('an oversized view coarsens to a complete grid within the six-tile cap', as
await h.update();
assert.equal(h.clicks.collection.values.length, 1);
assert.equal(h.clicks.collection.values[0].id, 'wildlife:inat:1');
assert.match(h.layer.getStats().countLabel, /sightings in view/);
assert.match(h.layer.getStats().countLabel, /sightings? in view/);
assert.equal(layerFeedState(h.layer.getStats()), 'nominal');
h.layer.destroy();
});