1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-06-27 16:35:57 +00:00
forgejo/options/locale_next
Benedikt Straub cf03286b5b Replace the 'relative-time' element scripting with custom, translatable rewrite (#6154)
This is my take to fix #6078
Should also resolve #6111

As far as I can tell, Forgejo uses only a subset of the relative-time functionality, and as far as I can see, this subset can be implemented using browser built-in date conversion and arithmetic. So I wrote a JavaScript to format the relative-time element accordingly, and a Go binding to generate the translated elements.

This is my first time writing Go code, and my first time coding for a large-scale server application, so please tell me if I'm doing something wrong, or if the whole approach is not acceptable.

---

Screenshot: Localized times in Low German
![grafik](/attachments/6f787e17-e666-4b88-8599-af0b8357ffbe)
Screenshot: The same with Forgejo in English
![grafik](/attachments/af09c873-b9f3-423d-b12b-7e62093e2623)

---

## Checklist

The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).

### Tests

- I added test coverage for Go changes...
  - [x] in their respective `*_test.go` for unit tests.
  - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I added test coverage for JavaScript changes...
  - [x] in `web_src/js/*.test.js` if it can be unit tested.
  - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).

### Documentation

- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [x] I did not document these changes and I do not expect someone else to do it.

### Release notes

- [x] I do not want this change to show in the release notes.
- [ ] I want the title to show in the release notes with a link to this pull request.
- [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6154
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Benedikt Straub <benedikt-straub@web.de>
Co-committed-by: Benedikt Straub <benedikt-straub@web.de>
2025-05-03 14:11:01 +00:00
..
locale_ar.json Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
locale_be.json Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
locale_bg.json fix(i18n): flatten next locales (#6607) 2025-01-18 07:35:28 +00:00
locale_bn.json Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
locale_bs.json Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
locale_ca.json i18n: update of translations from Codeberg Translate 2025-03-16 06:50:16 +00:00
locale_cs-CZ.json i18n: update of translations from Codeberg Translate 2025-05-01 09:50:01 +00:00
locale_da.json i18n: update of translations from Codeberg Translate 2025-04-10 05:25:01 +00:00
locale_de-DE.json i18n: update of translations from Codeberg Translate 2025-05-01 09:50:01 +00:00
locale_el-GR.json i18n: update of translations from Codeberg Translate 2025-03-16 06:50:16 +00:00
locale_en-US.json Replace the 'relative-time' element scripting with custom, translatable rewrite (#6154) 2025-05-03 14:11:01 +00:00
locale_eo.json i18n: update of translations from Codeberg Translate 2025-03-16 06:50:16 +00:00
locale_es-ES.json i18n: update of translations from Codeberg Translate 2025-04-24 06:35:00 +00:00
locale_et.json i18n: update of translations from Codeberg Translate 2025-03-16 06:50:16 +00:00
locale_fa-IR.json i18n: update of translations from Codeberg Translate (#7066) 2025-03-07 14:26:37 +00:00
locale_fi-FI.json i18n: update of translations from Codeberg Translate 2025-05-01 09:50:01 +00:00
locale_fil.json i18n: update of translations from Codeberg Translate 2025-04-10 05:25:01 +00:00
locale_fr-FR.json i18n: update of translations from Codeberg Translate 2025-03-16 06:50:16 +00:00
locale_gl.json Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
locale_hi.json Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
locale_hu-HU.json i18n: update of translations from Codeberg Translate 2025-03-16 06:50:16 +00:00
locale_id-ID.json fix(i18n): flatten next locales (#6607) 2025-01-18 07:35:28 +00:00
locale_is-IS.json fix(i18n): flatten next locales (#6607) 2025-01-18 07:35:28 +00:00
locale_it-IT.json i18n: update of translations from Codeberg Translate 2025-04-03 07:02:09 +00:00
locale_ja-JP.json i18n: update of translations from Codeberg Translate 2025-03-16 06:50:16 +00:00
locale_ko-KR.json i18n: update of translations from Codeberg Translate 2025-04-24 06:35:00 +00:00
locale_lt.json i18n: update of translations from Codeberg Translate 2025-03-16 06:50:16 +00:00
locale_lv-LV.json i18n: update of translations from Codeberg Translate 2025-04-10 05:25:01 +00:00
locale_ml-IN.json Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
locale_nb_NO.json Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
locale_nds.json i18n: update of translations from Codeberg Translate 2025-05-01 09:50:01 +00:00
locale_nl-NL.json i18n: update of translations from Codeberg Translate 2025-04-10 05:25:01 +00:00
locale_pl-PL.json i18n: update of translations from Codeberg Translate 2025-04-24 06:35:00 +00:00
locale_pt-BR.json i18n: update of translations from Codeberg Translate 2025-04-17 14:36:28 +00:00
locale_pt-PT.json i18n: update of translations from Codeberg Translate 2025-04-17 14:36:28 +00:00
locale_ru-RU.json i18n: update of translations from Codeberg Translate 2025-04-10 05:25:01 +00:00
locale_si-LK.json fix(i18n): flatten next locales (#6607) 2025-01-18 07:35:28 +00:00
locale_sk-SK.json i18n: update of translations from Codeberg Translate 2025-04-24 06:35:00 +00:00
locale_sl.json Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
locale_sr-SP.json Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
locale_sv-SE.json i18n: update of translations from Codeberg Translate 2025-03-16 06:50:16 +00:00
locale_tr-TR.json i18n: update of translations from Codeberg Translate 2025-03-16 06:50:16 +00:00
locale_uk-UA.json i18n: update of translations from Codeberg Translate 2025-05-01 09:50:01 +00:00
locale_vi.json Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
locale_yi.json Initial support for localization and pluralization with go-i18n-JSON-v2 format 2025-01-17 11:21:28 +01:00
locale_zh-CN.json i18n: update of translations from Codeberg Translate 2025-05-01 09:50:01 +00:00
locale_zh-HK.json fix(i18n): flatten next locales (#6607) 2025-01-18 07:35:28 +00:00
locale_zh-TW.json i18n: update of translations from Codeberg Translate 2025-05-01 09:50:01 +00:00