Skip to content

Allow pass locale to Duration toHuman #1738

@NogaMan

Description

@NogaMan

Is your feature request related to a problem? Please describe.
We don't have fully localized app yet and are in the process of localizing parts one by one.
That's why we can't use Settings.defaultLocale to set the locale once. Instead we pass locale explicitly where the formats are already localized.
For Duration I see there is no way to set locale before (or at the moment of) calling .toHuman.
That will be great to have that feature

Describe the solution you'd like
Allow passing locale to .toHuman:

Duration.fromDurationLike({ seconds: 12000 })
  .rescale()
  .toHuman({ locale: 'ja' });

and allow to set locale similar to DateTime:

Duration.fromDurationLike({ seconds: 12000 })
  .rescale()
  .setLocale('ja')
  .toHuman();

Describe alternatives you've considered
The alternative is to set default locale globally Settings.defaultLocale = 'ja';, but it wont work for us, as we are not fully localized yet.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions