Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

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

@TimStepanovAtBrandBoosting

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions