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

+40
View File
@@ -7,6 +7,7 @@ import assert from 'node:assert/strict';
import { createPinia } from 'pinia';
import { createApp, defineComponent, h, nextTick } from 'vue';
import { CockpitViewController } from './cockpitController.js';
import { setLocale } from '../i18n/index.js';
import { useCockpitStore } from './stores/cockpit.js';
import CockpitView from './views/CockpitView.vue';
import ContextView from './views/ContextView.vue';
@@ -355,6 +356,33 @@ test('the bridge radar shows nearby ships without its own and steps its range',
assert.ok(!$('#cockpit-radar') || $('#cockpit-radar').hidden);
});
test('the radar range and ring spacing agree with their distance (ru)', async (t) => {
const { $, cockpit } = fixture(t);
t.after(() => setLocale('en'));
setLocale('ru');
cockpit.enter();
await settle();
const shown = () => [
$('#cockpit-radar-range').textContent.trim(),
$('.cockpit-radar-rings').textContent.trim(),
];
// The ring spacing is a fraction at the short ranges: Intl.PluralRules
// gives 0.75 and 1.5 the form of their own.
const expected = [
['3 МОР. МИЛИ', 'КОЛЬЦА 0,75 МОР. МИЛИ'],
['6 МОР. МИЛЬ', 'КОЛЬЦА 1,5 МОР. МИЛИ'],
['12 МОР. МИЛЬ', 'КОЛЬЦА 3 МОР. МИЛИ'],
['24 МОР. МИЛИ', 'КОЛЬЦА 6 МОР. МИЛЬ'],
];
for (const [index, labels] of expected.entries()) {
if (index) {
$('#cockpit-radar-range').click();
await settle();
}
assert.deepEqual(shown(), labels);
}
});
test('contact navigation does not jump ship from the bridge', async (t) => {
const { cockpit, navigations } = fixture(t);
cockpit.enter();
@@ -1201,6 +1229,18 @@ test('a ship with no true heading is held, and labelled, on its course', async (
signals.some(([, , , detail]) => /COURSE 095°/.test(detail)),
JSON.stringify(signals),
);
// A ship's course has a word of its own: pt RUMO, an aircraft's CURSO.
t.after(() => setLocale('en'));
setLocale('pt');
signals.length = 0;
cockpit.exit();
await settle();
cockpit.enter();
await settle();
assert.ok(
signals.some(([, , , detail]) => /· RUMO 095°$/.test(detail)),
JSON.stringify(signals),
);
});
test('both entries name the subject the same way', async () => {
+5 -2
View File
@@ -1,5 +1,5 @@
/** Instrument values, routes and vision controls for the Cockpit controller. */
import { formatNumber, t } from '../i18n/index.js';
import { formatNumber, t, tn } from '../i18n/index.js';
import {
COCKPIT_VISION_MODES,
normalizeCockpitVisionMode,
@@ -379,7 +379,10 @@ export function updateRadar(info) {
);
this.publishRadar({
...picture,
rangeLabel: t('{range} NM', { range: formatNumber(rangeNm) }),
// A plural, as the ring spacing is: ru «3 МОР. МИЛИ», «12 МОР. МИЛЬ».
rangeLabel: tn(rangeNm, '{range} NM', '{range} NM', {
range: formatNumber(rangeNm),
}),
});
}
+8
View File
@@ -13,6 +13,7 @@ import { createPinia } from 'pinia';
import { createApp, defineComponent, h, nextTick } from 'vue';
import * as Cesium from 'cesium';
import { CockpitViewController } from './cockpitController.js';
import { setLocale, t as translate } from '../i18n/index.js';
import { useCockpitStore } from './stores/cockpit.js';
import { useHudStore } from './stores/hud.js';
import CockpitView from './views/CockpitView.vue';
@@ -534,6 +535,13 @@ test('a site row turns the camera onto it, holds it, and reads its off-nadir ang
assert.match(held.className, /^track actionable$/);
assert.match(held.detail, /^FOCUS · BASE · OFF-NADIR/);
assert.equal(siteRow(scene, 'alpha').getAttribute('aria-label'), 'Release the camera from Camp Alpha');
// The held site's FOCUS is a status, worded apart from the FOCUS command.
t.after(() => setLocale('en'));
setLocale('es');
await refreshRows(scene);
const heldEs = rows(scene).find((row) => row.target?.id === SITES.alpha.id);
assert.match(heldEs.detail, /^ENFOCADO · /);
assert.equal(translate('FOCUS'), 'ENFOCAR', 'the command keeps its verb');
});
test('another site row switches the focus; the held site row ends it', async (t) => {
+2 -1
View File
@@ -132,7 +132,8 @@ function siteRows(info, { settled = true } = {}) {
}),
});
const words = [installationClassLabel(site.class), angle];
if (focused) words.unshift(t('FOCUS'));
// A status, not the FOCUS command: es «ENFOCADO», not «ENFOCAR».
if (focused) words.unshift(t('FOCUS', { context: 'site status' }));
return {
key: `site:${site.id}`,
// The held site reads as the subject does.
+14
View File
@@ -7,6 +7,7 @@ import assert from 'node:assert/strict';
import { createPinia } from 'pinia';
import { createApp, defineComponent, h, nextTick } from 'vue';
import { CockpitViewController } from './cockpitController.js';
import { setLocale } from '../i18n/index.js';
import { useCockpitStore } from './stores/cockpit.js';
import CockpitView from './views/CockpitView.vue';
import ContextView from './views/ContextView.vue';
@@ -255,3 +256,16 @@ test('entering asks for a panel layout before Vue shows the cards', async (t) =>
await new Promise((resolve) => setTimeout(resolve, 50));
assert.deepEqual(laid, ['context', 'signals']);
});
test('an aircraft is acquired on its CURSO in Portuguese; a ship keeps RUMO', async (t) => {
const { cockpit } = fixture(t);
t.after(() => setLocale('en'));
setLocale('pt');
const signals = [];
cockpit.pushCockpitSignal = (...args) => signals.push(args);
cockpit.enter();
await nextTick();
const acquired = signals.find(([key]) => key === 'track');
assert.ok(acquired, JSON.stringify(signals));
assert.equal(acquired[3], 'UAL123 · CURSO 092°');
});
+3 -1
View File
@@ -326,9 +326,11 @@ export function enter({ kind = null } = {}) {
'track',
t('TRACK ACQUIRED'),
// A ship with no true heading is held on its course over ground; one
// with neither is named without a direction.
// with neither is named without a direction. A ship's course has a
// word of its own: pt «RUMO», where an aircraft's is «CURSO».
info.trackSource === 'course'
? t('{label} · COURSE {heading}°', {
context: 'vessel',
label: info.name,
heading: trackHeading,
})
+34 -11
View File
@@ -1,6 +1,6 @@
<script setup>
import { computed } from 'vue';
import { t } from '../../i18n/index.js';
import { formatNumber, t, tn } from '../../i18n/index.js';
import UiButton from '../kit/UiButton.vue';
import UiEmpty from '../kit/UiEmpty.vue';
import UiSelect from '../kit/UiSelect.js';
@@ -63,9 +63,15 @@ const categoryOptions = computed(() => [
const windowOptions = computed(() =>
(props.view?.windowChoices ?? []).map((hours) => ({
value: String(hours),
label: t('Last {hours} h', { hours }),
label: lastHours(hours),
})),
);
// The window offers 1 h, so every hour count is a plural: es «Última 1 h».
function lastHours(hours) {
return tn(hours, 'Last {hours} h', 'Last {hours} h', {
hours: formatNumber(hours),
});
}
// The longest choice is the server's whole window, kept as no choice.
const chooseWindow = (hours) =>
setFilter('hours', hours === props.view?.windowChoices?.[0] ? null : hours);
@@ -109,7 +115,16 @@ const clear = () => props.onParams({ clear: true });
<section
v-if="view"
class="news-readout"
:aria-label="t('News, last {hours} hours', { hours: view.windowHours })"
:aria-label="
tn(
view.windowHours,
'News, last {hours} hour',
'News, last {hours} hours',
{
hours: formatNumber(view.windowHours),
},
)
"
>
<UiSelect
v-if="windowOptions.length > 1"
@@ -120,7 +135,7 @@ const clear = () => props.onParams({ clear: true });
@update:model-value="chooseWindow(Number($event))"
/>
<p v-else class="news-readout__window ui-mono">{{
t('Last {hours} h', { hours: view.windowHours })
lastHours(view.windowHours)
}}</p>
<div
class="news-readout__sections"
@@ -196,9 +211,12 @@ const clear = () => props.onParams({ clear: true });
v-else-if="!view.inView.items.length && !view.inView.loading"
class="news-readout__empty"
:title="
t('Nothing reported near here in the last {hours} h', {
hours: view.windowHours,
})
tn(
view.windowHours,
'Nothing reported near here in the last {hours} h',
'Nothing reported near here in the last {hours} h',
{ hours: formatNumber(view.windowHours) },
)
"
/>
<ol
@@ -223,7 +241,9 @@ const clear = () => props.onParams({ clear: true });
class="news-readout__section"
:aria-label="t('Latest news')"
>
<h3 class="news-readout__head ui-mono">{{ t('Latest') }}</h3>
<h3 class="news-readout__head ui-mono">{{
t('Latest', { context: 'news list' })
}}</h3>
<UiEmpty
v-if="view.key"
class="news-readout__empty"
@@ -247,9 +267,12 @@ const clear = () => props.onParams({ clear: true });
v-else-if="!view.loading && !view.error"
class="news-readout__empty"
:title="
t('No news matches these filters in the last {hours} h', {
hours: view.windowHours,
})
tn(
view.windowHours,
'No news matches these filters in the last {hours} h',
'No news matches these filters in the last {hours} h',
{ hours: formatNumber(view.windowHours) },
)
"
/>
<div class="news-readout__footer">
+50
View File
@@ -1,6 +1,7 @@
import '../testSupport/registerDom.mjs';
import test from 'node:test';
import assert from 'node:assert/strict';
import { setLocale, t as translate } from '../i18n/index.js';
import { createNewsPanel } from './newsPanel.js';
import {
NEWS_CATEGORIES,
@@ -385,6 +386,55 @@ test('the window choice offers shorter windows; the longest is the server window
assert.deepEqual(calls.at(-1)[1], { filters: { hours: null } });
});
test('the time window agrees with its number of hours', (t) => {
t.after(() => setLocale('en'));
setLocale('es');
const { news, panel } = fixture();
news.update(view({ windowHours: 24, windowChoices: [24, 12, 6, 3, 1] }));
const choice = panel.querySelector(
'select.news-readout__window-choice, .news-readout__window-choice select',
);
assert.deepEqual(
[...choice.options].map((option) => option.textContent),
['Últimas 24 h', 'Últimas 12 h', 'Últimas 6 h', 'Últimas 3 h', 'Última 1 h'],
);
news.update(view({ windowHours: 1, items: [], hasMore: false }));
assert.equal(
panel.querySelector('.news-readout__window').textContent,
'Última 1 h',
);
assert.equal(
panel.querySelector('.news-readout').getAttribute('aria-label'),
'Noticias de la última 1 hora',
);
assert.match(
panel.textContent,
/En la última 1 h no hay noticias que coincidan con estos filtros/,
);
setLocale('ru');
news.update(view({ windowHours: 1, items: [], hasMore: false }));
assert.equal(
panel.querySelector('.news-readout').getAttribute('aria-label'),
'Новости за последний 1 час',
);
news.update(view({ windowHours: 12, items: [], hasMore: false }));
assert.equal(
panel.querySelector('.news-readout').getAttribute('aria-label'),
'Новости за последние 12 часов',
);
news.destroy();
});
test('the Latest news heading is worded apart from the timeline button (fr)', (t) => {
t.after(() => setLocale('en'));
setLocale('fr');
const { news, panel } = fixture();
news.update(view());
assert.equal(panel.querySelector('.news-readout__head').textContent, 'Dernières');
assert.equal(translate('Latest'), 'Dernière', 'the timeline keeps its own');
news.destroy();
});
test('the panel names the window the server serves', () => {
const { news, panel } = fixture();
news.update(view({ windowHours: 12 }));
+3 -1
View File
@@ -118,9 +118,11 @@ const ringFractions = computed(() =>
? radar.value.ringsNm.map((ring) => ring / radar.value.rangeNm)
: [],
);
// The spacing is a fraction at the shorter ranges (0.75, 1.5 NM), which
// Intl.PluralRules gives a form of its own: ru «0,75 МОР. МИЛИ».
const ringLabel = computed(() =>
radar.value?.ringsNm.length
? t('RINGS {spacing} NM', {
? tn(radar.value.ringsNm[0], 'RINGS {spacing} NM', 'RINGS {spacing} NM', {
spacing: formatNumber(radar.value.ringsNm[0]),
})
: '',
@@ -163,6 +163,20 @@ test('filters narrow the list as the viewer types and picks', async (t_) => {
assert.deepEqual(shownIds(), ['nasa-eonet-events']);
});
test('the shown count agrees with its number (he)', async (t_) => {
const { owner } = mount(t_);
setLocale('he');
owner.open();
await settle();
const status = () => $('.data-library-status').textContent.trim();
assert.match(status(), /^מוצגים\s+\S*3\S*\s+מתוך/);
const search = $('#data-library input[type="search"]');
search.value = 'eonet';
search.dispatchEvent(new Event('input'));
await settle();
assert.match(status(), /^מוצג\s+\S*1\S*\s+מתוך/);
});
test('Add becomes Remove on the same focused button; Zoom closes first', async (t_) => {
const { owner, library } = mount(t_);
owner.open();
+11 -5
View File
@@ -1,7 +1,7 @@
<script setup>
import { storeToRefs } from 'pinia';
import { computed, nextTick, useTemplateRef, watch } from 'vue';
import { t, tn } from '../../../i18n/index.js';
import { formatNumber, t, tn } from '../../../i18n/index.js';
import UiButton from '../../kit/UiButton.vue';
import UiSelect from '../../kit/UiSelect.js';
import {
@@ -53,12 +53,18 @@ watch(
const tiles = computed(() => libraryStatTiles(props.view.summary));
const themes = computed(() => libraryThemeOptions());
// The words for the shown entries agree with their count: he «מוצג 1».
const status = computed(() =>
props.view.ready
? t('Showing {shown} of {total}', {
shown: props.view.shown.length,
total: props.view.total,
})
? tn(
props.view.shown.length,
'Showing {shown} of {total}',
'Showing {shown} of {total}',
{
shown: formatNumber(props.view.shown.length),
total: formatNumber(props.view.total),
},
)
: t('Checking what this instance serves…'),
);
const resetText = computed(() => {