Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add locale ja-Hira #2663

Merged
merged 1 commit into from Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
116 changes: 116 additions & 0 deletions src/locale/ja-Hira/_lib/formatDistance/index.js
@@ -0,0 +1,116 @@
var formatDistanceLocale = {
lessThanXSeconds: {
one: '1びょうみまん',
other: '{{count}}びょうみまん',
oneWithSuffix: 'やく1びょう',
otherWithSuffix: 'やく{{count}}びょう'
},

xSeconds: {
one: '1びょう',
other: '{{count}}びょう'
},

halfAMinute: '30びょう',

lessThanXMinutes: {
one: '1ぷんみまん',
other: '{{count}}ふんみまん',
oneWithSuffix: 'やく1ぷん',
otherWithSuffix: 'やく{{count}}ふん'
},

xMinutes: {
one: '1ぷん',
other: '{{count}}ふん'
},

aboutXHours: {
one: 'やく1じかん',
other: 'やく{{count}}じかん'
},

xHours: {
one: '1じかん',
other: '{{count}}じかん'
},

xDays: {
one: '1にち',
other: '{{count}}にち'
},

aboutXWeeks: {
one: 'やく1しゅうかん',
other: 'やく{{count}}しゅうかん'
},

xWeeks: {
one: '1しゅうかん',
other: '{{count}}しゅうかん'
},

aboutXMonths: {
one: 'やく1かげつ',
other: 'やく{{count}}かげつ'
},

xMonths: {
one: '1かげつ',
other: '{{count}}かげつ'
},

aboutXYears: {
one: 'やく1ねん',
other: 'やく{{count}}ねん'
},

xYears: {
one: '1ねん',
other: '{{count}}ねん'
},

overXYears: {
one: '1ねんいじょう',
other: '{{count}}ねんいじょう'
},

almostXYears: {
one: '1ねんちかく',
other: '{{count}}ねんちかく'
}
}

export default function formatDistance(token, count, options) {
options = options || {}

var result
if (typeof formatDistanceLocale[token] === 'string') {
result = formatDistanceLocale[token]
} else if (count === 1) {
if (options.addSuffix && formatDistanceLocale[token].oneWithSuffix) {
result = formatDistanceLocale[token].oneWithSuffix
} else {
result = formatDistanceLocale[token].one
}
} else {
if (options.addSuffix && formatDistanceLocale[token].otherWithSuffix) {
result = formatDistanceLocale[token].otherWithSuffix.replace(
'{{count}}',
count
)
} else {
result = formatDistanceLocale[token].other.replace('{{count}}', count)
}
}

if (options.addSuffix) {
if (options.comparison > 0) {
return result + 'あと'
} else {
return result + 'まえ'
}
}

return result
}
41 changes: 41 additions & 0 deletions src/locale/ja-Hira/_lib/formatLong/index.js
@@ -0,0 +1,41 @@
import buildFormatLongFn from '../../../_lib/buildFormatLongFn/index'

var dateFormats = {
full: 'yねんMがつdにちEEEE',
long: 'yねんMがつdにち',
medium: 'y/MM/dd',
short: 'y/MM/dd'
}

var timeFormats = {
full: 'Hじmmふんssびょう zzzz',
long: 'H:mm:ss z',
medium: 'H:mm:ss',
short: 'H:mm'
}

var dateTimeFormats = {
full: '{{date}} {{time}}',
long: '{{date}} {{time}}',
medium: '{{date}} {{time}}',
short: '{{date}} {{time}}'
}

var formatLong = {
date: buildFormatLongFn({
formats: dateFormats,
defaultWidth: 'full'
}),

time: buildFormatLongFn({
formats: timeFormats,
defaultWidth: 'full'
}),

dateTime: buildFormatLongFn({
formats: dateTimeFormats,
defaultWidth: 'full'
})
}

export default formatLong
12 changes: 12 additions & 0 deletions src/locale/ja-Hira/_lib/formatRelative/index.js
@@ -0,0 +1,12 @@
var formatRelativeLocale = {
lastWeek: 'せんしゅうのeeeeのp',
yesterday: 'きのうのp',
today: 'きょうのp',
tomorrow: 'あしたのp',
nextWeek: 'よくしゅうのeeeeのp',
other: 'P'
}

export default function formatRelative(token, _date, _baseDate, _options) {
return formatRelativeLocale[token]
}
191 changes: 191 additions & 0 deletions src/locale/ja-Hira/_lib/localize/index.js
@@ -0,0 +1,191 @@
import buildLocalizeFn from '../../../_lib/buildLocalizeFn/index'

var eraValues = {
narrow: ['BC', 'AC'],
abbreviated: ['きげんぜん', 'せいれき'],
wide: ['きげんぜん', 'せいれき'],
}

var quarterValues = {
narrow: ['1', '2', '3', '4'],
abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
wide: ['だい1しはんき', 'だい2しはんき', 'だい3しはんき', 'だい4しはんき'],
}

var 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がつ',
],
}

var dayValues = {
narrow: ['にち', 'げつ', 'か', 'すい', 'もく', 'きん', 'ど'],
short: ['にち', 'げつ', 'か', 'すい', 'もく', 'きん', 'ど'],
abbreviated: ['にち', 'げつ', 'か', 'すい', 'もく', 'きん', 'ど'],
wide: ['にちようび', 'げつようび', 'かようび', 'すいようび', 'もくようび', 'きんようび', 'どようび'],
}

var 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: 'しんや',
},
}
var 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: 'しんや',
},
}

function ordinalNumber(dirtyNumber, dirtyOptions) {
var number = Number(dirtyNumber)

// If ordinal numbers depend on context, for example,
// if they are different for different grammatical genders,
// use `options.unit`:
//
// var options = dirtyOptions || {}
// var unit = String(options.unit)
//
// where `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
// 'day', 'hour', 'minute', 'second'

var options = dirtyOptions || {}
var 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}`
}
}

var localize = {
ordinalNumber: ordinalNumber,

era: buildLocalizeFn({
values: eraValues,
defaultWidth: 'wide',
}),

quarter: buildLocalizeFn({
values: quarterValues,
defaultWidth: 'wide',
argumentCallback: function (quarter) {
return 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',
}),
}

export default localize