Skip to content

Commit

Permalink
Merge pull request #1830 from iamkun/dev
Browse files Browse the repository at this point in the history
D2M
  • Loading branch information
andrewhood125ruhuc committed Mar 24, 2029
2 parents c635cd9 + ee23694 commit c975d9f
Show file tree
Hide file tree
Showing 20 changed files with 401 additions and 49 deletions.
4 changes: 3 additions & 1 deletion docs/es-es/README-es-es.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<p align="center"><a href="#" target="_blank" rel="noopener noreferrer"><img width="550"
Español (España) | [English](../../README.md) | [简体中文](../zh-cn/README.zh-CN.md) | [日本語](../ja/README-ja.md) | [Português Brasileiro](../pt-br/README-pt-br.md) | [한국어](../ko/README-ko.md) | [Русский](../ru/README-ru.md)

<p align="center"><a href="https://day.js.org/" target="_blank" rel="noopener noreferrer"><img width="550"
src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png"
alt="Day.js"></a></p>
<p align="center">Alternativa rápida y ligera <b>2kB</b> a Moment.js, con la misma API moderna</p>
Expand Down
4 changes: 3 additions & 1 deletion docs/ja/README-ja.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<p align="center"><a href="#" target="_blank" rel="noopener noreferrer"><img width="550"
日本語 | [English](../../README.md) | [简体中文](../zh-cn/README.zh-CN.md) | [Português Brasileiro](../pt-br/README-pt-br.md) | [한국어](../ko/README-ko.md) | [Español (España)](../es-es/README-es-es.md) | [Русский](../ru/README-ru.md)

<p align="center"><a href="https://day.js.org/" target="_blank" rel="noopener noreferrer"><img width="550"
src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png"
alt="Day.js"></a></p>
<p align="center">Moment.js と同じ API を備えた <b>2kB</b> の軽量ライブラリ</p>
Expand Down
4 changes: 3 additions & 1 deletion docs/ko/README-ko.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<p align="center"><a href="#" target="_blank" rel="noopener noreferrer"><img width="550"
한국어 | [English](../../README.md) | [简体中文](../zh-cn/README.zh-CN.md) | [日本語](../ja/README-ja.md) | [Português Brasileiro](../pt-br/README-pt-br.md) | [Español (España)](../es-es/README-es-es.md) | [Русский](../ru/README-ru.md)

<p align="center"><a href="https://day.js.org/" target="_blank" rel="noopener noreferrer"><img width="550"
src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png"
alt="Day.js"></a></p>
<p align="center">Moment.js와 호환되는 API를 가진 경량 라이브러리 (<b>2kB</b>)</p>
Expand Down
4 changes: 3 additions & 1 deletion docs/pt-br/README-pt-br.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<p align="center"><a href="#" target="_blank" rel="noopener noreferrer"><img width="550"
Português Brasileiro | [English](../../README.md) | [简体中文](../zh-cn/README.zh-CN.md) | [日本語](../ja/README-ja.md) | [한국어](../ko/README-ko.md) | [Español (España)](../es-es/README-es-es.md) | [Русский](../ru/README-ru.md)

<p align="center"><a href="https://day.js.org/" target="_blank" rel="noopener noreferrer"><img width="550"
src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png"
alt="Day.js"></a></p>
<p align="center">Alternativa veloz ao Moment.js, com <b>2kB</b> e a mesma API moderna</p>
Expand Down
6 changes: 4 additions & 2 deletions docs/ru/README-ru.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<p align="center"><a href="#" target="_blank" rel="noopener noreferrer"><img width="550"
Русский | [English](../../README.md) | [简体中文](../zh-cn/README.zh-CN.md) | [日本語](../ja/README-ja.md) | [Português Brasileiro](../pt-br/README-pt-br.md) | [한국어](../ko/README-ko.md) | [Español (España)](../es-es/README-es-es.md)

<p align="center"><a href="https://day.js.org/ru/" target="_blank" rel="noopener noreferrer"><img width="550"
src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png"
alt="Day.js"></a></p>
<p align="center">Быстрая <b>2kB</b> альтернатива Moment.js с тем же современным API</p>
Expand Down Expand Up @@ -27,7 +29,7 @@
dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss');
```

* 🕒 Хорошо знакомые API и паттерны Moment.js
* 🕒 Хорошо знакомые API и паттерны Moment.js
* 💪 Неизменная
* 🔥 Цепная
* 🌐 Поддержка интернационализации (I18n)
Expand Down
4 changes: 3 additions & 1 deletion docs/zh-cn/README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<p align="center"><a href="#" target="_blank" rel="noopener noreferrer"><img width="550"
简体中文 | [English](../../README.md) | [日本語](../ja/README-ja.md) | [Português Brasileiro](../pt-br/README-pt-br.md) | [한국어](../ko/README-ko.md) | [Español (España)](../es-es/README-es-es.md) | [Русский](../ru/README-ru.md)

<p align="center"><a href="https://day.js.org/zh-CN/" target="_blank" rel="noopener noreferrer"><img width="550"
src="https://user-images.githubusercontent.com/17680888/39081119-3057bbe2-456e-11e8-862c-646133ad4b43.png"
alt="Day.js"></a></p>
<p align="center">Moment.js 的 <b>2kB</b> 轻量化方案,拥有同样强大的 API</p>
Expand Down
13 changes: 9 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ const parseLocale = (preset, object, isLocal) => {
let l
if (!preset) return L
if (typeof preset === 'string') {
if (Ls[preset]) {
l = preset
const presetLower = preset.toLowerCase()
if (Ls[presetLower]) {
l = presetLower
}
if (object) {
Ls[preset] = object
l = preset
Ls[presetLower] = object
l = presetLower
}
const presetSplit = preset.split('-')
if (!l && presetSplit.length > 1) {
return parseLocale(presetSplit[0])
}
} else {
const { name } = preset
Expand Down
44 changes: 33 additions & 11 deletions src/locale/de-at.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
// German (Austria) [de-at]
import dayjs from 'dayjs'

const texts = {
s: 'ein paar Sekunden',
m: ['eine Minute', 'einer Minute'],
mm: '%d Minuten',
h: ['eine Stunde', 'einer Stunde'],
hh: '%d Stunden',
d: ['ein Tag', 'einem Tag'],
dd: ['%d Tage', '%d Tagen'],
M: ['ein Monat', 'einem Monat'],
MM: ['%d Monate', '%d Monaten'],
y: ['ein Jahr', 'einem Jahr'],
yy: ['%d Jahre', '%d Jahren']
}

function relativeTimeFormatter(number, withoutSuffix, key) {
let l = texts[key]
if (Array.isArray(l)) {
l = l[withoutSuffix ? 0 : 1]
}
return l.replace('%d', number)
}

const locale = {
name: 'de-at',
weekdays: 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
Expand All @@ -21,17 +43,17 @@ const locale = {
relativeTime: {
future: 'in %s',
past: 'vor %s',
s: 'ein paar Sekunden',
m: 'einer Minute',
mm: '%d Minuten',
h: 'einer Stunde',
hh: '%d Stunden',
d: 'einem Tag',
dd: '%d Tagen',
M: 'einem Monat',
MM: '%d Monaten',
y: 'einem Jahr',
yy: '%d Jahren'
s: relativeTimeFormatter,
m: relativeTimeFormatter,
mm: relativeTimeFormatter,
h: relativeTimeFormatter,
hh: relativeTimeFormatter,
d: relativeTimeFormatter,
dd: relativeTimeFormatter,
M: relativeTimeFormatter,
MM: relativeTimeFormatter,
y: relativeTimeFormatter,
yy: relativeTimeFormatter
}
}

Expand Down
46 changes: 41 additions & 5 deletions src/locale/de-ch.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,62 @@
// German (Switzerland) [de-ch]
import dayjs from 'dayjs'

const texts = {
s: 'ein paar Sekunden',
m: ['eine Minute', 'einer Minute'],
mm: '%d Minuten',
h: ['eine Stunde', 'einer Stunde'],
hh: '%d Stunden',
d: ['ein Tag', 'einem Tag'],
dd: ['%d Tage', '%d Tagen'],
M: ['ein Monat', 'einem Monat'],
MM: ['%d Monate', '%d Monaten'],
y: ['ein Jahr', 'einem Jahr'],
yy: ['%d Jahre', '%d Jahren']
}

function relativeTimeFormatter(number, withoutSuffix, key) {
let l = texts[key]
if (Array.isArray(l)) {
l = l[withoutSuffix ? 0 : 1]
}
return l.replace('%d', number)
}

const locale = {
name: 'de-ch',
weekdays: 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
months: 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
weekStart: 1,
weekdaysShort: 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
monthsShort: 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'),
weekdaysMin: 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
ordinal: n => n,
months: 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort: 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'),
ordinal: n => `${n}.`,
weekStart: 1,
formats: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD.MM.YYYY',
LL: 'D. MMMM YYYY',
LLL: 'D. MMMM YYYY HH:mm',
LLLL: 'dddd, D. MMMM YYYY HH:mm'
},
relativeTime: {
future: 'in %s',
past: 'vor %s',
s: relativeTimeFormatter,
m: relativeTimeFormatter,
mm: relativeTimeFormatter,
h: relativeTimeFormatter,
hh: relativeTimeFormatter,
d: relativeTimeFormatter,
dd: relativeTimeFormatter,
M: relativeTimeFormatter,
MM: relativeTimeFormatter,
y: relativeTimeFormatter,
yy: relativeTimeFormatter
}
}

dayjs.locale(locale, null, true)

export default locale

2 changes: 1 addition & 1 deletion src/locale/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const locale = {
weekdaysShort: 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
weekdaysMin: 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
months: 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort: 'Jan_Feb_März_Apr_Mai_Juni_Juli_Aug_Sept_Okt_Nov_Dez'.split('_'),
monthsShort: 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'),
ordinal: n => `${n}.`,
weekStart: 1,
yearStart: 4,
Expand Down
17 changes: 16 additions & 1 deletion src/locale/gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,29 @@ const locale = {
weekdaysShort: 'dom._lun._mar._mér._xov._ven._sáb.'.split('_'),
monthsShort: 'xan._feb._mar._abr._mai._xuñ._xul._ago._set._out._nov._dec.'.split('_'),
weekdaysMin: 'do_lu_ma_mé_xo_ve_sá'.split('_'),
ordinal: n => n,
ordinal: n => `${n}º`,
formats: {
LT: 'H:mm',
LTS: 'H:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D [de] MMMM [de] YYYY',
LLL: 'D [de] MMMM [de] YYYY H:mm',
LLLL: 'dddd, D [de] MMMM [de] YYYY H:mm'
},
relativeTime: {
future: 'en %s',
past: 'fai %s',
s: 'uns segundos',
m: 'un minuto',
mm: '%d minutos',
h: 'unha hora',
hh: '%d horas',
d: 'un día',
dd: '%d días',
M: 'un mes',
MM: '%d meses',
y: 'un ano',
yy: '%d anos'
}
}

Expand Down
55 changes: 54 additions & 1 deletion src/locale/is.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
// Icelandic [is]
import dayjs from 'dayjs'

const texts = {
s: ['nokkrar sekúndur', 'nokkrar sekúndur', 'nokkrum sekúndum'],
m: ['mínúta', 'mínútu', 'mínútu'],
mm: ['mínútur', 'mínútur', 'mínútum'],
h: ['klukkustund', 'klukkustund', 'klukkustund'],
hh: ['klukkustundir', 'klukkustundir', 'klukkustundum'],
d: ['dagur', 'dag', 'degi'],
dd: ['dagar', 'daga', 'dögum'],
M: ['mánuður', 'mánuð', 'mánuði'],
MM: ['mánuðir', 'mánuði', 'mánuðum'],
y: ['ár', 'ár', 'ári'],
yy: ['ár', 'ár', 'árum']
}

function resolveTemplate(key, number, isFuture, withoutSuffix) {
const suffixIndex = isFuture
? 1
: 2

const index = withoutSuffix
? 0
: suffixIndex

const keyShouldBeSingular = key.length === 2 && number % 10 === 1

const correctedKey = keyShouldBeSingular ? key[0] : key
const unitText = texts[correctedKey]
const text = unitText[index]
return key.length === 1
? text
: `%d ${text}`
}

function relativeTimeFormatter(number, withoutSuffix, key, isFuture) {
const template = resolveTemplate(key, number, isFuture, withoutSuffix)

return template.replace('%d', number)
}

const locale = {
name: 'is',
weekdays: 'sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur'.split('_'),
Expand All @@ -17,10 +56,24 @@ const locale = {
LL: 'D. MMMM YYYY',
LLL: 'D. MMMM YYYY [kl.] H:mm',
LLLL: 'dddd, D. MMMM YYYY [kl.] H:mm'
},
relativeTime: {
future: 'eftir %s',
past: 'fyrir %s síðan',
s: relativeTimeFormatter,
m: relativeTimeFormatter,
mm: relativeTimeFormatter,
h: relativeTimeFormatter,
hh: relativeTimeFormatter,
d: relativeTimeFormatter,
dd: relativeTimeFormatter,
M: relativeTimeFormatter,
MM: relativeTimeFormatter,
y: relativeTimeFormatter,
yy: relativeTimeFormatter
}
}

dayjs.locale(locale, null, true)

export default locale

1 change: 1 addition & 0 deletions src/locale/ku.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const locale = {
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd, D MMMM YYYY HH:mm'
},
meridiem: hour => (hour < 12 ? 'پ.ن' : 'د.ن'),
relativeTime: {
future: 'له‌ %s',
past: '%s',
Expand Down
40 changes: 40 additions & 0 deletions src/locale/rn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Kirundi [rn]
import dayjs from 'dayjs'

const locale = {
name: 'rn',
weekdays: 'Ku wa Mungu_Ku wa Mbere_Ku wa Kabiri_Ku wa Gatatu_Ku wa Kane_Ku wa Gatanu_Ku wa Gatandatu'.split('_'),
weekdaysShort: 'Kngu_Kmbr_Kbri_Ktat_Kkan_Ktan_Kdat'.split('_'),
weekdaysMin: 'K7_K1_K2_K3_K4_K5_K6'.split('_'),
months: 'Nzero_Ruhuhuma_Ntwarante_Ndamukiza_Rusama_Ruhenshi_Mukakaro_Myandagaro_Nyakanga_Gitugutu_Munyonyo_Kigarama'.split('_'),
monthsShort: 'Nzer_Ruhuh_Ntwar_Ndam_Rus_Ruhen_Muk_Myand_Nyak_Git_Muny_Kig'.split('_'),
weekStart: 1,
ordinal: n => n,
relativeTime: {
future: 'mu %s',
past: '%s',
s: 'amasegonda',
m: 'Umunota',
mm: '%d iminota',
h: 'isaha',
hh: '%d amasaha',
d: 'Umunsi',
dd: '%d iminsi',
M: 'ukwezi',
MM: '%d amezi',
y: 'umwaka',
yy: '%d imyaka'
},
formats: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd, D MMMM YYYY HH:mm'
}
}

dayjs.locale(locale, null, true)

export default locale
Loading

0 comments on commit c975d9f

Please sign in to comment.