mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
i18n(ja): ship Japanese
- 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]>
This commit is contained in:
1 parent
7ad073aa9c
commit
ed40201481
12 files changed
+221
-16
No files matched your search
+13
-2
@@ -1,4 +1,4 @@
|
||||
import { formatNumber, msg, t } from '../i18n/index.js';
|
||||
import { formatNumber, getLocale, msg, t } from '../i18n/index.js';
|
||||
|
||||
// Unit ids stay English in data, params and AI-tool readings; only the label
|
||||
// shown on the page is translated. dBZ and °C read the same in every language.
|
||||
@@ -23,6 +23,17 @@ export function unitLabel(unit) {
|
||||
return Object.hasOwn(UNIT_LABELS, unit) ? t(UNIT_LABELS[unit]) : unit || '';
|
||||
}
|
||||
|
||||
/**
|
||||
* What goes between a number and its unit label: a no-break space, except
|
||||
* before a Japanese unit word, which follows the number directly (5分, 1時間).
|
||||
*/
|
||||
export function quantitySeparator(label) {
|
||||
return getLocale() === 'ja' &&
|
||||
/^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]/u.test(label)
|
||||
? ''
|
||||
: '\u00a0';
|
||||
}
|
||||
|
||||
/**
|
||||
* A number and its unit that never break apart: "22,0 км/ч". Readings carry
|
||||
* no digit grouping ("1008 hPa"), as on weather charts.
|
||||
@@ -30,7 +41,7 @@ export function unitLabel(unit) {
|
||||
export function formatQuantity(value, unit, options) {
|
||||
const label = unitLabel(unit);
|
||||
const number = formatNumber(value, { useGrouping: false, ...options });
|
||||
return label ? `${number}\u00a0${label}` : number;
|
||||
return label ? `${number}${quantitySeparator(label)}${label}` : number;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user