timepiece/node_modules/date-fns/locale/ja/_lib/localize.mjs

178 lines
3.4 KiB
JavaScript
Raw Normal View History

2024-05-14 14:54:12 +00:00
import { buildLocalizeFn } from "../../_lib/buildLocalizeFn.mjs";
const eraValues = {
narrow: ["BC", "AC"],
abbreviated: ["紀元前", "西暦"],
wide: ["紀元前", "西暦"],
};
const quarterValues = {
narrow: ["1", "2", "3", "4"],
abbreviated: ["Q1", "Q2", "Q3", "Q4"],
wide: ["第1四半期", "第2四半期", "第3四半期", "第4四半期"],
};
const monthValues = {
narrow: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
abbreviated: [
"1月",
"2月",
"3月",
"4月",
"5月",
"6月",
"7月",
"8月",
"9月",
"10月",
"11月",
"12月",
],
wide: [
"1月",
"2月",
"3月",
"4月",
"5月",
"6月",
"7月",
"8月",
"9月",
"10月",
"11月",
"12月",
],
};
const dayValues = {
narrow: ["日", "月", "火", "水", "木", "金", "土"],
short: ["日", "月", "火", "水", "木", "金", "土"],
abbreviated: ["日", "月", "火", "水", "木", "金", "土"],
wide: ["日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"],
};
const dayPeriodValues = {
narrow: {
am: "午前",
pm: "午後",
midnight: "深夜",
noon: "正午",
morning: "朝",
afternoon: "午後",
evening: "夜",
night: "深夜",
},
abbreviated: {
am: "午前",
pm: "午後",
midnight: "深夜",
noon: "正午",
morning: "朝",
afternoon: "午後",
evening: "夜",
night: "深夜",
},
wide: {
am: "午前",
pm: "午後",
midnight: "深夜",
noon: "正午",
morning: "朝",
afternoon: "午後",
evening: "夜",
night: "深夜",
},
};
const formattingDayPeriodValues = {
narrow: {
am: "午前",
pm: "午後",
midnight: "深夜",
noon: "正午",
morning: "朝",
afternoon: "午後",
evening: "夜",
night: "深夜",
},
abbreviated: {
am: "午前",
pm: "午後",
midnight: "深夜",
noon: "正午",
morning: "朝",
afternoon: "午後",
evening: "夜",
night: "深夜",
},
wide: {
am: "午前",
pm: "午後",
midnight: "深夜",
noon: "正午",
morning: "朝",
afternoon: "午後",
evening: "夜",
night: "深夜",
},
};
const ordinalNumber = (dirtyNumber, options) => {
const number = Number(dirtyNumber);
const unit = String(options?.unit);
switch (unit) {
case "year":
return `${number}`;
case "quarter":
return `${number}四半期`;
case "month":
return `${number}`;
case "week":
return `${number}`;
case "date":
return `${number}`;
case "hour":
return `${number}`;
case "minute":
return `${number}`;
case "second":
return `${number}`;
default:
return `${number}`;
}
};
export const localize = {
ordinalNumber: ordinalNumber,
era: buildLocalizeFn({
values: eraValues,
defaultWidth: "wide",
}),
quarter: buildLocalizeFn({
values: quarterValues,
defaultWidth: "wide",
argumentCallback: (quarter) => Number(quarter) - 1,
}),
month: buildLocalizeFn({
values: monthValues,
defaultWidth: "wide",
}),
day: buildLocalizeFn({
values: dayValues,
defaultWidth: "wide",
}),
dayPeriod: buildLocalizeFn({
values: dayPeriodValues,
defaultWidth: "wide",
formattingValues: formattingDayPeriodValues,
defaultFormattingWidth: "wide",
}),
};