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

add basic support for hu and lt localizations #864

Merged
merged 5 commits into from Sep 18, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 4 additions & 4 deletions src/esm/fp/index.js
Expand Up @@ -101,21 +101,21 @@ export {default as getDateWithOptions} from './getDateWithOptions/index.js'
export {default as getDay} from './getDay/index.js'
export {default as getDayOfYear} from './getDayOfYear/index.js'
export {default as getDayOfYearWithOptions} from './getDayOfYearWithOptions/index.js'
export {default as getDayWithOptions} from './getDayWithOptions/index.js'
export {default as getDaysInMonth} from './getDaysInMonth/index.js'
export {default as getDaysInMonthWithOptions} from './getDaysInMonthWithOptions/index.js'
export {default as getDaysInYear} from './getDaysInYear/index.js'
export {default as getDaysInYearWithOptions} from './getDaysInYearWithOptions/index.js'
export {default as getDayWithOptions} from './getDayWithOptions/index.js'
export {default as getHours} from './getHours/index.js'
export {default as getHoursWithOptions} from './getHoursWithOptions/index.js'
export {default as getISODay} from './getISODay/index.js'
export {default as getISODayWithOptions} from './getISODayWithOptions/index.js'
export {default as getISOWeek} from './getISOWeek/index.js'
export {default as getISOWeekWithOptions} from './getISOWeekWithOptions/index.js'
export {default as getISOWeekYear} from './getISOWeekYear/index.js'
export {default as getISOWeekYearWithOptions} from './getISOWeekYearWithOptions/index.js'
export {default as getISOWeeksInYear} from './getISOWeeksInYear/index.js'
export {default as getISOWeeksInYearWithOptions} from './getISOWeeksInYearWithOptions/index.js'
export {default as getISOWeekWithOptions} from './getISOWeekWithOptions/index.js'
export {default as getISOYear} from './getISOYear/index.js'
export {default as getISOYearWithOptions} from './getISOYearWithOptions/index.js'
export {default as getMilliseconds} from './getMilliseconds/index.js'
export {default as getMillisecondsWithOptions} from './getMillisecondsWithOptions/index.js'
export {default as getMinutes} from './getMinutes/index.js'
Expand Down
10 changes: 10 additions & 0 deletions src/esm/locale/index.js
Expand Up @@ -7,6 +7,16 @@ export {default as enUS} from './en-US/index.js'
export {default as eo} from './eo/index.js'
export {default as es} from './es/index.js'
export {default as fr} from './fr/index.js'
export {default as frCH} from './fr-CH/index.js'
export {default as hr} from './hr/index.js'
export {default as hu} from './hu/index.js'
export {default as id} from './id/index.js'
export {default as is} from './is/index.js'
export {default as it} from './it/index.js'
export {default as ja} from './ja/index.js'
export {default as ko} from './ko/index.js'
export {default as lt} from './lt/index.js'
export {default as mk} from './mk/index.js'
pardoeryanair marked this conversation as resolved.
Show resolved Hide resolved
export {default as nb} from './nb/index.js'
export {default as nl} from './nl/index.js'
export {default as ptBR} from './pt-BR/index.js'
Expand Down
8 changes: 4 additions & 4 deletions src/fp/index.js
Expand Up @@ -102,21 +102,21 @@ module.exports = {
getDay: require('./getDay/index.js'),
getDayOfYear: require('./getDayOfYear/index.js'),
getDayOfYearWithOptions: require('./getDayOfYearWithOptions/index.js'),
getDayWithOptions: require('./getDayWithOptions/index.js'),
getDaysInMonth: require('./getDaysInMonth/index.js'),
getDaysInMonthWithOptions: require('./getDaysInMonthWithOptions/index.js'),
getDaysInYear: require('./getDaysInYear/index.js'),
getDaysInYearWithOptions: require('./getDaysInYearWithOptions/index.js'),
getDayWithOptions: require('./getDayWithOptions/index.js'),
getHours: require('./getHours/index.js'),
getHoursWithOptions: require('./getHoursWithOptions/index.js'),
getISODay: require('./getISODay/index.js'),
getISODayWithOptions: require('./getISODayWithOptions/index.js'),
getISOWeek: require('./getISOWeek/index.js'),
getISOWeekWithOptions: require('./getISOWeekWithOptions/index.js'),
getISOWeekYear: require('./getISOWeekYear/index.js'),
getISOWeekYearWithOptions: require('./getISOWeekYearWithOptions/index.js'),
getISOWeeksInYear: require('./getISOWeeksInYear/index.js'),
getISOWeeksInYearWithOptions: require('./getISOWeeksInYearWithOptions/index.js'),
getISOWeekWithOptions: require('./getISOWeekWithOptions/index.js'),
getISOYear: require('./getISOYear/index.js'),
getISOYearWithOptions: require('./getISOYearWithOptions/index.js'),
getMilliseconds: require('./getMilliseconds/index.js'),
getMillisecondsWithOptions: require('./getMillisecondsWithOptions/index.js'),
getMinutes: require('./getMinutes/index.js'),
Expand Down
91 changes: 91 additions & 0 deletions src/locale/hu/_lib/formatDistance/index.js
@@ -0,0 +1,91 @@
var formatDistanceLocale = {
lessThanXSeconds: {
one: 'kevesebb, mint egy másodperce',
other: 'kevesebb, mint {{count}} másodperce'
},

xSeconds: {
one: '1 másodperce',
other: '{{count}} másodperce'
},

halfAMinute: 'fél perce',

lessThanXMinutes: {
one: 'kevesebb, mint egy perce',
other: 'kevesebb, mint {{count}} perce'
},

xMinutes: {
one: '1 perce',
other: '{{count}} perce'
},

aboutXHours: {
one: 'közel 1 órája',
other: 'közel {{count}} órája'
},

xHours: {
one: '1 órája',
other: '{{count}} órája'
},

xDays: {
one: '1 napja',
other: '{{count}} napja'
},

aboutXMonths: {
one: 'közel 1 hónapja',
other: 'közel {{count}} hónapja'
},

xMonths: {
one: '1 hónapja',
other: '{{count}} hónapja'
},

aboutXYears: {
one: 'közel 1 éve',
other: 'közel {{count}} éve'
},

xYears: {
one: '1 éve',
other: '{{count}} éve'
},

overXYears: {
one: 'több, mint 1 éve',
other: 'több, mint {{count}} éve'
},

almostXYears: {
one: 'majdnem 1 éve',
other: 'majdnem {{count}} éve'
}
}

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

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

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

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

var formatLong = buildFormatLongFn({
LT: 'H:mm',
LTS: 'H:mm:ss',
L: 'YYYY.MM.DD.',
LL: 'YYYY. MMMM D.',
LLL: 'YYYY. MMMM D. H:mm',
LLLL: 'YYYY. MMMM D., dddd H:mm'
})

export default formatLong
27 changes: 27 additions & 0 deletions src/locale/hu/_lib/formatRelative/index.js
@@ -0,0 +1,27 @@
var accusativeWeekdays = ['vasárnap', 'hétfőn', 'kedden', 'szerdán', 'csütörtökön', 'pénteken', 'szombaton']

function week (isFuture) {
return function (date, baseDate, options) {
var day = date.getUTCDay()
return (isFuture ? '' : '[múlt] ') + '[' + accusativeWeekdays[day] + '] LT[-kor]'
}
}

var formatRelativeLocale = {
lastWeek: week(false),
yesterday: '[tegnap] LT[-kor]',
today: '[ma] LT[-kor]',
tomorrow: '[holnap] LT[-kor]',
nextWeek: week(true),
other: 'L'
}

export default function formatRelative (token, date, baseDate, options) {
var format = formatRelativeLocale[token]

if (typeof format === 'function') {
return format(date, baseDate, options)
}

return format
}
49 changes: 49 additions & 0 deletions src/locale/hu/_lib/localize/index.js
@@ -0,0 +1,49 @@
import buildLocalizeFn from '../../../_lib/buildLocalizeFn/index.js'
import buildLocalizeArrayFn from '../../../_lib/buildLocalizeArrayFn/index.js'

var weekdayValues = {
narrow: ['v', 'h', 'k', 'sze', 'cs', 'p', 'szo'],
short: ['vas', 'hét', 'kedd', 'sze', 'csüt', 'pén', 'szo'],
long: ['vasárnap', 'hétfő', 'kedd', 'szerda', 'csütörtök', 'péntek', 'szombat']
}

var monthValues = {
short: ['jan', 'feb', 'márc', 'ápr', 'máj', 'jún', 'júl', 'aug', 'szept', 'okt', 'nov', 'dec'],
long: ['január', 'február', 'március', 'április', 'május', 'június', 'július', 'augusztus', 'szeptember', 'október', 'november', 'december']
}

var timeOfDayValues = {
uppercase: ['DE', 'DU'],
lowercase: ['de', 'du'],
long: ['délelőtt', 'délután']
}

function ordinalNumber (dirtyNumber, dirtyOptions) {
var number = Number(dirtyNumber)
var rem100 = number % 100
if (rem100 > 20 || rem100 < 10) {
switch (rem100 % 10) {
case 1:
return number + 'st'
case 2:
return number + 'nd'
case 3:
return number + 'rd'
}
}
return number + 'th'
}

var localize = {
ordinalNumber: ordinalNumber,
weekday: buildLocalizeFn(weekdayValues, 'long'),
weekdays: buildLocalizeArrayFn(weekdayValues, 'long'),
month: buildLocalizeFn(monthValues, 'long'),
months: buildLocalizeArrayFn(monthValues, 'long'),
timeOfDay: buildLocalizeFn(timeOfDayValues, 'long', function (hours) {
return (hours / 12) >= 1 ? 1 : 0
}),
timesOfDay: buildLocalizeArrayFn(timeOfDayValues, 'long')
}

export default localize
17 changes: 17 additions & 0 deletions src/locale/hu/index.js
@@ -0,0 +1,17 @@
import formatDistance from './_lib/formatDistance/index.js'
import formatLong from './_lib/formatLong/index.js'
import formatRelative from './_lib/formatRelative/index.js'
import localize from './_lib/localize/index.js'

var locale = {
pardoeryanair marked this conversation as resolved.
Show resolved Hide resolved
formatDistance: formatDistance,
formatLong: formatLong,
formatRelative: formatRelative,
localize: localize,
options: {
weekStartsOn: 1,
firstWeekContainsDate: 4
}
}

export default locale
37 changes: 37 additions & 0 deletions src/locale/hu/index.js.flow
@@ -0,0 +1,37 @@
// @flow
// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it.

type Locale = {
formatDistance: Function,
formatLong: Function,
formatRelative: Function,
localize: {
ordinalNumber: Function,
weekday: Function,
weekdays: Function,
month: Function,
months: Function,
timeOfDay: Function,
timesOfDay: Function
},
match: {
ordinalNumbers: Function,
ordinalNumber: Function,
weekdays: Function,
weekday: Function,
months: Function,
month: Function,
timesOfDay: Function,
timeOfDay: Function
},
formatters?: Object,
formattingTokensRegExp?: RegExp,
units?: Object,
parsers?: Object,
parsingTokensRegExp?: RegExp,
options?: {
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6
}
}

declare module.exports: Locale
10 changes: 10 additions & 0 deletions src/locale/index.js
Expand Up @@ -8,6 +8,16 @@ module.exports = {
eo: require('./eo/index.js'),
es: require('./es/index.js'),
fr: require('./fr/index.js'),
frCH: require('./fr-CH/index.js'),
hr: require('./hr/index.js'),
hu: require('./hu/index.js'),
id: require('./id/index.js'),
is: require('./is/index.js'),
it: require('./it/index.js'),
ja: require('./ja/index.js'),
ko: require('./ko/index.js'),
lt: require('./lt/index.js'),
mk: require('./mk/index.js'),
pardoeryanair marked this conversation as resolved.
Show resolved Hide resolved
nb: require('./nb/index.js'),
nl: require('./nl/index.js'),
ptBR: require('./pt-BR/index.js'),
Expand Down
2 changes: 2 additions & 0 deletions src/locale/index.js.flow
Expand Up @@ -52,12 +52,14 @@ declare module.exports: {
frCH: Locale,
he: Locale,
hr: Locale,
hu: Locale,
id: Locale,
is: Locale,
it: Locale,
ja: Locale,
ka: Locale,
ko: Locale,
lt: Locale,
mk: Locale,
ms: Locale,
nb: Locale,
Expand Down
16 changes: 16 additions & 0 deletions src/locale/lt/_lib/formatLong/index.js
@@ -0,0 +1,16 @@
import buildFormatLongFn from '../../../_lib/buildFormatLongFn/index.js'

var formatLong = buildFormatLongFn({
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'YYYY-MM-DD',
LL: 'YYYY [m.] MMMM D [d.]',
LLL: 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
LLLL: 'YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]',
l: 'YYYY-MM-DD',
ll: 'YYYY [m.] MMMM D [d.]',
lll: 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
llll: 'YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]'
})

export default formatLong
12 changes: 12 additions & 0 deletions src/locale/lt/_lib/formatRelative/index.js
@@ -0,0 +1,12 @@
var formatRelativeLocale = {
lastWeek: '[Praėjusį] dddd LT',
yesterday: '[Vakar] LT',
today: '[Šiandien] LT',
tomorrow: '[Rytoj] LT',
nextWeek: 'dddd LT',
other: 'L'
}

export default function formatRelative (token, date, baseDate, options) {
return formatRelativeLocale[token]
}