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

Fix hungarian localization #1112

Merged
merged 4 commits into from
Oct 21, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/locale/hu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ const locale = {
relativeTime: {
future: '%s múlva',
past: '%s',
s: 'néhány másodperc',
m: 'egy perc',
mm: '%d perc',
h: 'egy óra',
hh: '%d óra',
d: 'egy nap',
dd: '%d nap',
M: 'egy hónap',
MM: '%d hónap',
y: 'egy éve',
yy: '%d év'
s: (_, s, ___, isFuture) => `néhány másodperc${isFuture || s ? '' : 'e'}`,
m: (_, s, ___, isFuture) => `egy perc${isFuture || s ? '' : 'e'}`,
mm: (n, s, ___, isFuture) => `${n} perc${isFuture || s ? '' : 'e'}`,
h: (_, s, ___, isFuture) => `egy ${isFuture || s ? 'óra' : 'órája'}`,
hh: (n, s, ___, isFuture) => `${n} ${isFuture || s ? 'óra' : 'órája'}`,
d: (_, s, ___, isFuture) => `egy ${isFuture || s ? 'nap' : 'napja'}`,
dd: (n, s, ___, isFuture) => `${n} ${isFuture || s ? 'nap' : 'napja'}`,
M: (_, s, ___, isFuture) => `egy ${isFuture || s ? 'hónap' : 'hónapja'}`,
MM: (n, s, ___, isFuture) => `${n} ${isFuture || s ? 'hónap' : 'hónapja'}`,
y: (_, s, ___, isFuture) => `egy ${isFuture || s ? 'év' : 'éve'}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vassbence, I think that here you could move év right after egy (just like you did with egy perc(e)). That would save you another two chars. 😉

yy: (n, s, ___, isFuture) => `${n} ${isFuture || s ? 'év' : 'éve'}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here (move év).

},
formats: {
LT: 'H:mm',
Expand All @@ -38,4 +38,3 @@ const locale = {
dayjs.locale(locale, null, true)

export default locale

45 changes: 45 additions & 0 deletions test/locale/hu.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import moment from 'moment'
import dayjs from '../../src'
import relativeTime from '../../src/plugin/relativeTime'
import '../../src/locale/hu'

dayjs.extend(relativeTime)

it('RelativeTime: Time from X', () => {
const T = [
[44.4, 'second'], // a few seconds
[89.5, 'second'], // a minute
[2, 'minute'], // 2 minutes
[43, 'minute'], // 43 minutes
[45, 'minute'], // an hour
[3, 'hour'], // 3 hours
[21, 'hour'], // 21 hours
[1, 'day'], // a day
[3, 'day'], // 3 day
[25, 'day'], // 25 days
[1, 'month'], // a month
[2, 'month'], // 2 month
[10, 'month'], // 10 month
[1, 'year'], // a year
[2, 'year'], // 2 year
[5, 'year'], // 5 year
[18, 'month'] // 2 years
]

T.forEach((t) => {
dayjs.locale('hu')
moment.locale('hu')

const dayjsDay = dayjs()
const momentDay = moment()

const dayjsCompare = dayjs().add(t[0], t[1])
const momentCompare = moment().add(t[0], t[1])

expect(dayjsDay.from(dayjsCompare)).toBe(momentDay.from(momentCompare))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t want to nitpick, however, I would remove the double empty lines (keep only one empty line).


expect(dayjsDay.to(dayjsCompare)).toBe(momentDay.to(momentCompare))

expect(dayjsDay.from(dayjsCompare, true)).toBe(momentDay.from(momentCompare, true))
})
})