mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
- Register ja: CATALOGS, LOCALES, LOCALE_NAMES (日本語) and the package boundaries; ja and ja-JP tags select it. - Japanese unit words follow the number directly, as in the catalog: formatQuantity writes 5分 and 1時間5分 (km and kt keep the space), and formatRelativeTime drops the space CLDR puts in 5 分前. - Tests: locale tags, picker order, Intl output, durations and the ramp/exit/lane wording in Japanese. - docs/translations/ja.md: style, units, plurals and glossary; ja added to TRANSLATORS.md and CURRENT-STATE.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
import test from 'node:test';
|
||
import assert from 'node:assert/strict';
|
||
import { setLocale } from '../i18n/index.js';
|
||
import { formatQuantity, formatScaleLabel, unitLabel } from './unitLabels.js';
|
||
|
||
test('English readings and scales read exactly as the unit ids', () => {
|
||
setLocale('en');
|
||
assert.equal(unitLabel('km/h'), 'km/h');
|
||
assert.equal(unitLabel('°C'), '°C');
|
||
assert.equal(unitLabel('dBZ'), 'dBZ');
|
||
assert.equal(unitLabel(''), '');
|
||
assert.equal(formatQuantity(95, 'kt'), '95 kt');
|
||
assert.equal(formatQuantity(1006, 'hPa'), '1006 hPa');
|
||
assert.equal(
|
||
formatQuantity(22, 'km/h', {
|
||
minimumFractionDigits: 1,
|
||
maximumFractionDigits: 1,
|
||
}),
|
||
'22.0 km/h',
|
||
);
|
||
assert.deepEqual(
|
||
['0.1', '-40', '1050+', '300+', 'Calm'].map(formatScaleLabel),
|
||
['0.1', '-40', '1050+', '300+', 'Calm'],
|
||
);
|
||
});
|
||
|
||
test('other languages get their decimal separator and no digit grouping', () => {
|
||
try {
|
||
setLocale('ru');
|
||
assert.match(
|
||
formatQuantity(22, 'km/h', {
|
||
minimumFractionDigits: 1,
|
||
maximumFractionDigits: 1,
|
||
}),
|
||
/^22,0 \S+$/,
|
||
);
|
||
assert.match(formatQuantity(1050, 'hPa'), /^1050 /);
|
||
assert.deepEqual(['0.1', '-40', '1050+'].map(formatScaleLabel), [
|
||
'0,1',
|
||
'-40',
|
||
'1050+',
|
||
]);
|
||
} finally {
|
||
setLocale('en');
|
||
}
|
||
});
|
||
|
||
test('Japanese unit words follow the number directly; symbols keep the space', () => {
|
||
try {
|
||
setLocale('ja');
|
||
assert.equal(formatQuantity(5, 'min'), '5分');
|
||
assert.equal(formatQuantity(1, 'h'), '1時間');
|
||
assert.equal(formatQuantity(95, 'kt'), '95\u00a0kt');
|
||
} finally {
|
||
setLocale('en');
|
||
}
|
||
});
|