eddiesigner / liebling

Beautiful and clean Ghost theme that is easy and comfortable to use. To get the latest version please head over the releases page 👉🏼
https://github.com/eddiesigner/liebling/releases
MIT License
1.27k stars 602 forks source link

formatDate() not returning zh-hans/zh-hant date string #489

Open HolgerHuo opened 1 year ago

HolgerHuo commented 1 year ago

formatDate() function uses Date.prototype.toLocaleDateString() to convert date string, which takes in BCP 47 Language Tags as locale setting. However, locale files are using zh-hans/zh-hant style formatting, causing the theme to unable to translate date strings.

We could either add a layer of translation between zh-hans/zh-hant to zh-cn/zh-hk or update locale jsons; however, the former one isn't very graceful while the latter may result in Breaking change. Maybe there is a better solution to this?

BTW, thanks for creating this theme!

HolgerHuo commented 1 year ago

Seems that to have all date displayed across the site to be correctly displayed in zh-hans/zh-hant locale, we will have to rename those jsons as Ghost's api can only take zh-cn/zh-hk style formatting.

eddiesigner commented 1 year ago

Hi,

The function formatDate() is only used to format the dates in search results when the native search is not enabled, all the rest of dates that are displayed across the pages don't use that function, Ghost handles that.

The locale files also don't handle dates, maybe this is an issue with Ghost itself, I would suggest you to reach their support team to see if they can find a proper solution.

HolgerHuo commented 1 year ago

Hi! Thanks for your reply.

The function formatDate() is only used to format the dates in search results when the native search is not enabled, all the rest of dates that are displayed across the pages don't use that function, Ghost handles that.

The rest of date locale follows this format for Chinese language: zh-cn/zh-hk. Maybe we should consider renaming the locales files' name to this format too as Ghost use zh-cn/zh-hk to select theme's language.