mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
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:
1 parent
42540ad85e
commit
209b135ff1
37 files changed
+1124
-196
No files matched your search
@@ -3917,6 +3917,8 @@ async function requestStreetLevel(
|
||||
};
|
||||
|
||||
// Then the place: a name that geocodes to nothing changes nothing else.
|
||||
// "the view centre" is English for the model; the card (speech.js) gives
|
||||
// it messages of its own, since it is a phrase and not a place name.
|
||||
label =
|
||||
query ||
|
||||
(entity ? String(entity.label || entity.id) : '') ||
|
||||
|
||||
+32
-11
@@ -332,6 +332,16 @@ const ERROR_PATTERNS = [
|
||||
place: localizePlaceName(place),
|
||||
}),
|
||||
],
|
||||
// show_street_level names no place when it looks at the view centre. The
|
||||
// phrase is not a name: it has a message of its own, so each language
|
||||
// words it in the case its preposition asks for.
|
||||
[
|
||||
/^No (.+) imagery near the view centre$/,
|
||||
([, source]) =>
|
||||
t('No {source} imagery near the view centre', {
|
||||
source: translateKnown(source),
|
||||
}),
|
||||
],
|
||||
[
|
||||
/^No (.+) imagery near (.+)$/,
|
||||
([, source, place]) =>
|
||||
@@ -1112,14 +1122,21 @@ export function planStepLabel(name, args = {}) {
|
||||
}
|
||||
case 'show_street_level': {
|
||||
const source = STREET_LEVEL_SOURCE_NAMES[args.provider];
|
||||
const place = args.query
|
||||
? shownPlace(args.query, 32)
|
||||
: args.latitude != null
|
||||
? t('this spot')
|
||||
: t('the view centre');
|
||||
// "This spot" and "the view centre" are phrases, not place names:
|
||||
// each is a message of its own, worded in the grammar of the language.
|
||||
if (args.query) {
|
||||
const place = shownPlace(args.query, 32);
|
||||
return source
|
||||
? t('{source} at {place}', { source, place })
|
||||
: t('Street level at {place}', { place });
|
||||
}
|
||||
if (args.latitude != null)
|
||||
return source
|
||||
? t('{source} at this spot', { source })
|
||||
: t('Street level at this spot');
|
||||
return source
|
||||
? t('{source} at {place}', { source, place })
|
||||
: t('Street level at {place}', { place });
|
||||
? t('{source} at the view centre', { source })
|
||||
: t('Street level at the view centre');
|
||||
}
|
||||
case 'set_layer_visibility': {
|
||||
const on = args.enabled !== false;
|
||||
@@ -1195,6 +1212,9 @@ export function narrationLabel(name, args = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
/** The place show_street_level reports when it names none (gevActions). */
|
||||
const VIEW_CENTRE_LABEL = 'the view centre';
|
||||
|
||||
/** On-screen labels for progress steps. */
|
||||
const STEP_LABELS = Object.freeze({
|
||||
resolve: msg('Finding places'),
|
||||
@@ -1219,10 +1239,11 @@ export function progressStepLabel(step, label) {
|
||||
: step
|
||||
? spokenLabel(step, 24)
|
||||
: t('Working');
|
||||
// The join is a catalog string so each language spaces its colon.
|
||||
return label
|
||||
? t('{name}: {state}', { name: base, state: spokenLabel(label, 32) })
|
||||
: base;
|
||||
// The join is a catalog string so each language spaces its colon. The
|
||||
// view centre is a phrase show_street_level reports in English, not a name.
|
||||
const state =
|
||||
label === VIEW_CENTRE_LABEL ? t('the view centre') : spokenLabel(label, 32);
|
||||
return label ? t('{name}: {state}', { name: base, state }) : base;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from './speech.js';
|
||||
import { presentResult } from './resultDisplay.js';
|
||||
import { countWords, findHedges } from './speechLint.js';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import { setLocale, t } from '../i18n/index.js';
|
||||
|
||||
function envelope(name, result, args) {
|
||||
return attachVoiceResult(name, result, args);
|
||||
@@ -779,3 +779,51 @@ test('progress step labels join through the catalog colon', () => {
|
||||
setLocale('en');
|
||||
}
|
||||
});
|
||||
|
||||
test('the street-level card words "the view centre" and "this spot" as phrases, not names', () => {
|
||||
setLocale('de');
|
||||
try {
|
||||
assert.equal(
|
||||
planStepLabel('show_street_level', { provider: 'mapillary' }),
|
||||
'Mapillary in der Bildmitte',
|
||||
);
|
||||
assert.equal(
|
||||
planStepLabel('show_street_level', { latitude: 1, longitude: 2 }),
|
||||
'Straßenebene an dieser Stelle',
|
||||
);
|
||||
assert.equal(
|
||||
planStepLabel('show_street_level', { query: 'Alexanderplatz', provider: 'kartaview' }),
|
||||
'KartaView: Alexanderplatz',
|
||||
);
|
||||
const empty = envelope('show_street_level', {
|
||||
ok: false,
|
||||
stage: 'imagery',
|
||||
noImagery: true,
|
||||
atViewCentre: true,
|
||||
label: 'the view centre',
|
||||
providerName: 'Mapillary',
|
||||
error: 'No Mapillary imagery near the view centre',
|
||||
});
|
||||
assert.deepEqual(empty.display.lines, [
|
||||
'Keine Bilder von Mapillary in der Nähe der Bildmitte',
|
||||
]);
|
||||
assert.equal(empty.say, 'No Mapillary imagery near the view centre.');
|
||||
const named = envelope('show_street_level', {
|
||||
ok: false,
|
||||
stage: 'imagery',
|
||||
noImagery: true,
|
||||
label: 'Alexanderplatz',
|
||||
providerName: 'Mapillary',
|
||||
error: 'No Mapillary imagery near Alexanderplatz',
|
||||
});
|
||||
assert.deepEqual(named.display.lines, [
|
||||
'Keine Bilder von Mapillary in der Nähe von Alexanderplatz',
|
||||
]);
|
||||
assert.equal(
|
||||
progressStepLabel('imagery', 'the view centre'),
|
||||
`${t('Opening imagery')}: die Bildmitte`,
|
||||
);
|
||||
} finally {
|
||||
setLocale('en');
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user