EvanHahn / HumanizeDuration.js

361000 becomes "6 minutes, 1 second"
https://evanhahn.github.io/HumanizeDuration.js/
The Unlicense
1.64k stars 175 forks source link

Add Vietnamese language #97

Closed J2TEAM closed 8 years ago

EvanHahn commented 8 years ago

Could you add tests? It will be a matter of making a vi.csv file in test/definitions.

J2TEAM commented 8 years ago

@EvanHahn I added test file!

EvanHahn commented 8 years ago

Looks like your tests have a failure when humanizing 0 milliseconds.

1) localized humanization for vi humanizes with arguments:
        AssertionError: '0 mili giâys' == '0 mili giây'

        + expected - actual

        -0 mili giâys
        +0 mili giây

Could you fix this?

J2TEAM commented 8 years ago

@EvanHahn I tried to edit the test file, but the results still failed. Because "giâys" is an invalid word, I don't know where it come from? (Not in humanize-duration.js or vi.csv)

EvanHahn commented 8 years ago

I think it's because you have functions like this:

s: function (c) { return 'giây' + (c !== 1 ? 's' : '') },

These will return "giây" if you run humanizeDuration(1, { language: 'vi' }) and "giâys" if you run humanizeDuration(2, { language: 'vi' }).

Should it look more like this?

vi: {
  y: 'năm',
  mo: 'tháng',
  w: 'tuần',
  d: 'ngày',
  h: 'giờ',
  m: 'phút',
  s: 'giây',
  ms: 'mili giây',
  decimal: ','
},
J2TEAM commented 8 years ago

@EvanHahn Oh, yeah. It seems I have focused to strings and forgot about the condition statements. I have updated humanize-duration.js

EvanHahn commented 8 years ago

Cảm ơn bạn! Merged manually in 6470e6fa15c03a71d7e0d905fbb78f0f41f0e9f3 (so that it is just one commit).

This will be released soon.

EvanHahn commented 8 years ago

This has been published in humanize-duration@3.7.0.