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

react-i18n: Issue with 'formatDate()' with 'humanize' style #2689

Open
TimStepanovAtBrandBoosting opened this issue Oct 17, 2023 · 2 comments
Labels
Type: Bug 🐛 Something isn't working

Comments

@TimStepanovAtBrandBoosting

Overview

I've been trying to implement date formatting using the DateStyle.Humanize style. I have been following the instructions in the readme file of that package.
This was my code I've been experimenting with:

const testStringDate = i18n.formatDate(new Date(), { style: DateStyle.Humanize });
console.log("testStringDate", testStringDate);

From reading the Readme file, I've been expecting this to just work, and produce an opinionated date string that "Adheres to Polaris guidelines for dates with times".
However instead I get an empty string. I also get an error log:

 MissingTranslationError: Missing translation for key: date.humanize.lessThanOneMinuteAgo in locale: en                                                                                                                                                     
     at Object.translate                                                            
     at I18n.translate                                                                                 
     at I18n.humanizePastDate                                                                   
     at I18n.humanizeDate                                                                              
     at I18n.formatDate                                                               
     at BulkDiscountCoupons                                                                           
     at renderWithHooks                                                              
     at renderIndeterminateComponent
     at renderElement
     at renderNodeDestructiveImpl 

From what I gather from this error, It expects me to provide the template for humanize myself. However this is not mentioned in the docs anywhere and I don't even know, how I should format it.

Is this a bug or an user error on my part? In the later case, it might be a good idea to update the documentation to be more clear about this.

@TimStepanovAtBrandBoosting TimStepanovAtBrandBoosting added the Type: Bug 🐛 Something isn't working label Oct 17, 2023
@YevhenTarashchyk
Copy link

Hi, have u managed to fix this problem ?

@TimStepanovAtBrandBoosting
Copy link
Author

I have not worked on that issue since, and just used ISO date formatting for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants