mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 02:14:01 +00:00
i18n(ja): address code review findings
Japanese has no letter case, so the HUD summary keeps units as the
catalog writes them (13 km), matching the cockpit and the ja HUD CSS.
The ja '{value} KM', '{value} KM/H' and '{value} KM/S' strings are now
lower-case like zh-CN.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
eab9632738
commit
a1d9847976
5 files changed
+33
-8
No files matched your search
@@ -8,7 +8,10 @@ import { formatNumber, getLocale, t } from './i18n/index.js';
|
|||||||
import { unitLabel } from './ui/unitLabels.js';
|
import { unitLabel } from './ui/unitLabels.js';
|
||||||
import { localizePlaceName } from './ui/placeNames.js';
|
import { localizePlaceName } from './ui/placeNames.js';
|
||||||
|
|
||||||
/** An upper-case HUD quantity such as `13KM` / `13КМ`, in the active language. */
|
/**
|
||||||
|
* An upper-case HUD quantity such as `13KM` / `13КМ`, in the active language.
|
||||||
|
* Chinese and Japanese have no case and keep the catalog's `13 km`.
|
||||||
|
*/
|
||||||
export function hudQuantity(value, unit, digits = 0) {
|
export function hudQuantity(value, unit, digits = 0) {
|
||||||
const number = formatNumber(value, {
|
const number = formatNumber(value, {
|
||||||
useGrouping: false,
|
useGrouping: false,
|
||||||
@@ -16,7 +19,7 @@ export function hudQuantity(value, unit, digits = 0) {
|
|||||||
maximumFractionDigits: digits,
|
maximumFractionDigits: digits,
|
||||||
});
|
});
|
||||||
const label = unitLabel(unit);
|
const label = unitLabel(unit);
|
||||||
if (getLocale().startsWith('zh-'))
|
if (/^(zh|ja)(-|$)/.test(getLocale()))
|
||||||
return label ? `${number} ${label}` : number;
|
return label ? `${number} ${label}` : number;
|
||||||
return `${number}${label.toUpperCase()}`;
|
return `${number}${label.toUpperCase()}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { setLocale } from './index.js';
|
||||||
|
import { hudQuantity, LOCALIZED_LOCALITY } from '../hudLocalityFormat.js';
|
||||||
|
import { formatCockpitDistance } from '../ui/cockpitPresentation.js';
|
||||||
|
|
||||||
|
// revmain-opus-ja-i1-1: ja has no case, so HUD units keep the catalog case
|
||||||
|
// (km), as the cockpit already does and docs/translations/ja.md requires.
|
||||||
|
test('Japanese HUD units keep their case, like the cockpit', () => {
|
||||||
|
try {
|
||||||
|
setLocale('ja');
|
||||||
|
assert.equal(formatCockpitDistance(14000), '14 km');
|
||||||
|
assert.equal(hudQuantity(13, 'km'), '13 km');
|
||||||
|
assert.equal(hudQuantity(1.5, 'km', 1), '1.5 km');
|
||||||
|
assert.equal(
|
||||||
|
LOCALIZED_LOCALITY.near({ poi: 'Shibuya', city: 'Tokyo', distKm: 13 }),
|
||||||
|
'SHIBUYA(東京)付近 13 km',
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
setLocale('en');
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -803,8 +803,8 @@
|
|||||||
"DATE UNAVAILABLE": "日付不明",
|
"DATE UNAVAILABLE": "日付不明",
|
||||||
"UNSPECIFIED OPERATOR": "運用者未指定",
|
"UNSPECIFIED OPERATOR": "運用者未指定",
|
||||||
"Select {mission}": "{mission}を選択",
|
"Select {mission}": "{mission}を選択",
|
||||||
"{value} KM": "{value} KM",
|
"{value} KM": "{value} km",
|
||||||
"{value} KM/S": "{value} KM/S",
|
"{value} KM/S": "{value} km/s",
|
||||||
"Selected Space Mission": "選択中の宇宙ミッション",
|
"Selected Space Mission": "選択中の宇宙ミッション",
|
||||||
"SELECTED SPACE MISSION": "選択中の宇宙ミッション",
|
"SELECTED SPACE MISSION": "選択中の宇宙ミッション",
|
||||||
"Show all missions": "すべてのミッションを表示",
|
"Show all missions": "すべてのミッションを表示",
|
||||||
@@ -1607,7 +1607,7 @@
|
|||||||
"REGION UNAVAILABLE": "地域を取得できません",
|
"REGION UNAVAILABLE": "地域を取得できません",
|
||||||
"NO RECENT LOCATION MATCHES": "この地域の最近のニュースなし",
|
"NO RECENT LOCATION MATCHES": "この地域の最近のニュースなし",
|
||||||
"{domain} · {age}": "{domain} · {age}",
|
"{domain} · {age}": "{domain} · {age}",
|
||||||
"{value} KM/H": "{value} KM/H",
|
"{value} KM/H": "{value} km/h",
|
||||||
"CLOUD {pct}%": "雲量 {pct}%",
|
"CLOUD {pct}%": "雲量 {pct}%",
|
||||||
"CLOUD UNKNOWN": "雲量不明",
|
"CLOUD UNKNOWN": "雲量不明",
|
||||||
"{source} · LOCATION QUERY": "{source} · 位置クエリ",
|
"{source} · LOCATION QUERY": "{source} · 位置クエリ",
|
||||||
|
|||||||
@@ -169,9 +169,6 @@
|
|||||||
"{source} HTTP {status}",
|
"{source} HTTP {status}",
|
||||||
"{speed} kn",
|
"{speed} kn",
|
||||||
"{type} SPD: {speed} HDG: {heading}",
|
"{type} SPD: {speed} HDG: {heading}",
|
||||||
"{value} KM",
|
|
||||||
"{value} KM/H",
|
|
||||||
"{value} KM/S",
|
|
||||||
"ΔE",
|
"ΔE",
|
||||||
"ΔN",
|
"ΔN",
|
||||||
"▲ {frp} MW"
|
"▲ {frp} MW"
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ test('Chinese HUD and cockpit units keep their case without spacing coordinates'
|
|||||||
assert.equal(formatCockpitDistance(14000), '14\u00a0km');
|
assert.equal(formatCockpitDistance(14000), '14\u00a0km');
|
||||||
assert.equal(LOCALIZED_LOCALITY.sector({ latDeg: 21.33, lonDeg: -77.5 }),
|
assert.equal(LOCALIZED_LOCALITY.sector({ latDeg: 21.33, lonDeg: -77.5 }),
|
||||||
'扇区 21.33N 77.50W');
|
'扇区 21.33N 77.50W');
|
||||||
|
setLocale('ja');
|
||||||
|
assert.equal(hudQuantity(13, 'km'), '13 km');
|
||||||
|
assert.equal(hudQuantity(1.5, 'km', 1), '1.5 km');
|
||||||
setLocale('en');
|
setLocale('en');
|
||||||
assert.equal(hudQuantity(0, 'km'), '0KM');
|
assert.equal(hudQuantity(0, 'km'), '0KM');
|
||||||
assert.equal(hudQuantity(2069, 'km', 1), '2069.0KM');
|
assert.equal(hudQuantity(2069, 'km', 1), '2069.0KM');
|
||||||
|
|||||||
Reference in new issue
Block a user