[PR #1457] [MERGED] Localized date fns #3552

Closed
opened 2026-04-25 00:16:06 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/1457
Author: @tomazed
Created: 1/30/2023
Status: Merged
Merged: 1/30/2023
Merged by: @advplyr

Base: masterHead: LocalizedDateFns


📝 Commits (8)

  • e8d5822 localized date-fns library
  • 41db0e3 Use Date-Fns locale to generate month and day labels
  • b5de517 Generate days from date-fns locale
  • a67213f Simplified languageCodeMap maintainability
  • db49400 Import all locales from date-fns/locale
  • 6183381 Removed unused strings from translations
  • 74d8a09 Merge branch 'master' into LocalizedDateFns
  • c4e2726 Update client/plugins/i18n.js

📊 Changes

13 files changed (+38 additions, -238 deletions)

View changed files

📝 client/components/stats/DailyListeningChart.vue (+1 -1)
📝 client/components/stats/Heatmap.vue (+4 -4)
📝 client/components/widgets/CronExpressionBuilder.vue (+7 -7)
📝 client/plugins/i18n.js (+11 -9)
📝 client/plugins/init.client.js (+7 -1)
📝 client/strings/de.json (+1 -27)
📝 client/strings/en-us.json (+1 -27)
📝 client/strings/es.json (+1 -27)
📝 client/strings/fr.json (+1 -27)
📝 client/strings/hr.json (+1 -27)
📝 client/strings/it.json (+1 -27)
📝 client/strings/pl.json (+1 -27)
📝 client/strings/zh-cn.json (+1 -27)

📄 Description

I took a shot at doing localization with date-fns
I do not like the lines

import { de as localeDE, enUS as localeENUS, es as localeES, fr as localeFR, hr as localeHR, it as localeIT, pl as localePL, zhCN as localeZNCN } from 'date-fns/locale'
let locale = {
  de: localeDE,
  enUS: localeENUS,
  es: localeES,
  fr: localeFR,
  hr: localeHR,
  it: localeIT,
  pl: localePL,
  znCN: localeZNCN
}

from https://github.com/advplyr/audiobookshelf/blob/master/client/plugins/init.client.js

but for the love of god, I could not simply do a import locale from 'date-fns/locale' just like stated in the docs
There must be a better way, but this one works...

I also took the liberty to generate the months and weekdays through date-fns format function. I think this render
https://github.com/advplyr/audiobookshelf/blob/5724887785b55a56c4e07505ea7c0d2384c0febf/client/strings/en-us.json#L630-L643
and
https://github.com/advplyr/audiobookshelf/blob/5724887785b55a56c4e07505ea7c0d2384c0febf/client/strings/en-us.json#L536-L547
useless


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/1457 **Author:** [@tomazed](https://github.com/tomazed) **Created:** 1/30/2023 **Status:** ✅ Merged **Merged:** 1/30/2023 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `LocalizedDateFns` --- ### 📝 Commits (8) - [`e8d5822`](https://github.com/advplyr/audiobookshelf/commit/e8d582269b8379bb6123f3ee2a3c5ae624963808) localized date-fns library - [`41db0e3`](https://github.com/advplyr/audiobookshelf/commit/41db0e3bb152f28e373ddfe89ca0064531ddda26) Use Date-Fns locale to generate month and day labels - [`b5de517`](https://github.com/advplyr/audiobookshelf/commit/b5de517aad11bf1acaccef767157e84cc34f761a) Generate days from date-fns locale - [`a67213f`](https://github.com/advplyr/audiobookshelf/commit/a67213fb7b590834fdb77947973ad058b596791c) Simplified languageCodeMap maintainability - [`db49400`](https://github.com/advplyr/audiobookshelf/commit/db494001a26a1493f3d2be436186babbf6913e50) Import all locales from date-fns/locale - [`6183381`](https://github.com/advplyr/audiobookshelf/commit/618338165e644642c06a4512451721e5fc5f63ff) Removed unused strings from translations - [`74d8a09`](https://github.com/advplyr/audiobookshelf/commit/74d8a09f3172ba25fb0b00e9be95a4018d3d5347) Merge branch 'master' into LocalizedDateFns - [`c4e2726`](https://github.com/advplyr/audiobookshelf/commit/c4e2726622015d0a4a2372961a40b640a4f00e0d) Update client/plugins/i18n.js ### 📊 Changes **13 files changed** (+38 additions, -238 deletions) <details> <summary>View changed files</summary> 📝 `client/components/stats/DailyListeningChart.vue` (+1 -1) 📝 `client/components/stats/Heatmap.vue` (+4 -4) 📝 `client/components/widgets/CronExpressionBuilder.vue` (+7 -7) 📝 `client/plugins/i18n.js` (+11 -9) 📝 `client/plugins/init.client.js` (+7 -1) 📝 `client/strings/de.json` (+1 -27) 📝 `client/strings/en-us.json` (+1 -27) 📝 `client/strings/es.json` (+1 -27) 📝 `client/strings/fr.json` (+1 -27) 📝 `client/strings/hr.json` (+1 -27) 📝 `client/strings/it.json` (+1 -27) 📝 `client/strings/pl.json` (+1 -27) 📝 `client/strings/zh-cn.json` (+1 -27) </details> ### 📄 Description I took a shot at doing localization with date-fns I do not like the lines ``` import { de as localeDE, enUS as localeENUS, es as localeES, fr as localeFR, hr as localeHR, it as localeIT, pl as localePL, zhCN as localeZNCN } from 'date-fns/locale' let locale = { de: localeDE, enUS: localeENUS, es: localeES, fr: localeFR, hr: localeHR, it: localeIT, pl: localePL, znCN: localeZNCN } ``` from https://github.com/advplyr/audiobookshelf/blob/master/client/plugins/init.client.js but for the love of god, I could not simply do a `import locale from 'date-fns/locale'` just like stated in the [docs](https://date-fns.org/v2.29.3/docs/setDefaultOptions#examples) There must be a better way, but this one works... I also took the liberty to generate the months and weekdays through date-fns format function. I think this render https://github.com/advplyr/audiobookshelf/blob/5724887785b55a56c4e07505ea7c0d2384c0febf/client/strings/en-us.json#L630-L643 and https://github.com/advplyr/audiobookshelf/blob/5724887785b55a56c4e07505ea7c0d2384c0febf/client/strings/en-us.json#L536-L547 useless --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:16:06 +02:00
adam closed this issue 2026-04-25 00:16:06 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3552