framework icon indicating copy to clipboard operation
framework copied to clipboard

feat: date time formats from locales

Open YUCLing opened this issue 5 months ago • 36 comments

Fixes https://github.com/flarum-lang/chinese-simplified/issues/23 and https://github.com/flarum-lang/chinese-simplified/issues/27 (in another way)

Changes proposed in this pull request: This PR adds some time formats to dayjs, which makes the customized time formats used by Flarum localizable in locale object of dayjs locales.

This PR makes Flarum formats all date time using the formats from the language packs.

The PR also made some improvements to humanTime and liveHumanTimes's comments.

Reviewers should focus on: The new formats' naming and whether is it a good implementation.

All language packs should contain the following formats after this is merged:

  • f and F: For humanTime
  • ff and FF: For scrubber

It's not necessary though, a fallback will be used if they are not provided.

Check if all date time are formatted using the format from the language pack.

Although I've tested on my local Flarum installation, it would be nice for you to test it again.

Screenshot

99f92af943c71dfd7c6a05685f23a12d 513c8b085de4959658de0f73765b49c6

QA All places where humanTime is used and post stream's scrubber.

Modify date time formats in locale and see if it works.

Necessity

  • [ ] Has the problem that is being solved here been clearly explained?
  • [ ] If applicable, have various options for solving this problem been considered?
  • [ ] For core PRs, does this need to be in core, or could it be in an extension?
  • [ ] Are we willing to maintain this for years / potentially forever?

Confirmed

  • [x] Frontend changes: tested on a local Flarum installation.
  • [ ] Backend changes: tests are green (run composer test).
  • [ ] Core developer confirmed locally this works as intended.
  • [ ] Tests have been added, or are not appropriate here.

Required changes:

  • [ ] Related documentation PR: (Remove if irrelevant)
  • [ ] Related core extension PRs: (Remove if irrelevant)

YUCLing avatar Sep 27 '24 15:09 YUCLing