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

Feature: Relative time for fusional languages #659

Closed

Conversation

tomas-ki
Copy link

Hi,

Currently there are several issues regarding relative time on fusional languages, this PR would address these issues (I hope I didn't miss any):
#610 #416 #415 #302

I have looked through moment implementation of relative time and adapted it to fit dayjs. I am aware that a lot of the this code is taken from moment, but I don't think that reinventing the wheel in this place is a good approach. I think it is okay to have moment as a point of truth for proper localization results, because translation is a very long process and this makes it easy to have correct translations even without knowing the language.

There are a couple of fixes in language translations (polish for example was completely off, since translating relative time to the past translates it as a future term, see "po 1 godziny" for example.).

I have also added preparsers/postparsers when needed. In this case Arabic locale numerals.

I've added tests and some helpers to reduce code duplication and add coverage to localized formats. Current implementation makes it easy to compare dayjs localization results with moment. There are some cases that are difficult to cover, so I'm leaving it not as 100% for now.

I've also added handling for relative time formats as functions, which addresses plural forms in most cases.

Thanks in advance for taking a moment (no pun intended) to look into this and please voice any concerns that you may have.

@codecov-io
Copy link

codecov-io commented Aug 13, 2019

Codecov Report

Merging #659 into dev will decrease coverage by 0.46%.
The diff coverage is 93.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #659      +/-   ##
==========================================
- Coverage   99.89%   99.43%   -0.47%     
==========================================
  Files         154      154              
  Lines         989     1055      +66     
  Branches      148      176      +28     
==========================================
+ Hits          988     1049      +61     
- Misses          1        5       +4     
- Partials        0        1       +1
Impacted Files Coverage Δ
src/locale/ja.js 100% <ø> (ø) ⬆️
src/locale/ru.js 100% <100%> (ø) ⬆️
src/locale/it.js 100% <100%> (ø) ⬆️
src/plugin/relativeTime/index.js 100% <100%> (ø) ⬆️
src/index.js 100% <100%> (ø) ⬆️
src/locale/ar.js 88.88% <86.95%> (-11.12%) ⬇️
src/locale/pl.js 90% <88.23%> (-10%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 95e70b4...2802abb. Read the comment docs.

@iamkun
Copy link
Owner

iamkun commented Jan 6, 2020

Thanks, but here's a simple one. #767

@iamkun iamkun closed this Jan 6, 2020
@it-xtech-dev
Copy link

Polish seems to be not handled in #767.

@iamkun
Copy link
Owner

iamkun commented Jan 19, 2020

Polish seems to be not handled in #767.

fix in d372475

@it-xtech-dev
Copy link

@iamkun how to know when / whether this fix is available in release (and which version)?

@iamkun
Copy link
Owner

iamkun commented Jan 21, 2020

next coming version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants