forgejo/modules/translation
forgejo-backport-action 4a97de08f4 [v15.0/forgejo] fix(i18n): don't log harmless missing translations as errors (#12185)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/12183

Followup to https://codeberg.org/forgejo/forgejo/pulls/6203

Currently it is logging an error wherever a template is rendered in language that doesn't have all plural strings covered. For example, Esperanto isn't well maintained.

Since more plural strings were migrated in v15 to new format, these errors became much more common. However, for all languages but the base one (English) they are completely harmless and just indicate an incomplete translation.

However, for base (English) they indicate a bug in either template or en-US.json, which should be still logged as an error.

The error is being logged by `LookupPluralByForm`, which is called by `TrPluralStringAllForms` and (`TrPluralString` through `LookupPluralByCount`). I originally intended to just pass log func directly to `LookupPluralByForm` from both, but since `TrPluralString` isn't calling `LookupPluralByForm` directly, it didn't look clean, so I went with passing a flag around instead and implemented logging logic in `LookupPluralByForm` itself.

I little concern is with that the so-called "default lang" is configurable, and if it is configured to something with less than 100% completion, it will cause fallback bugs, as well as a lot of logging of this as an error. But this is why changing "default lang" is a bad idea in the first place, and broken fallbacks should be greater concern than junk in the logs.

Co-authored-by: 0ko <0ko@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12185
Reviewed-by: Beowulf <beowulf@beocode.eu>
Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
2026-04-19 01:46:40 +02:00
..
i18n [v15.0/forgejo] fix(i18n): don't log harmless missing translations as errors (#12185) 2026-04-19 01:46:40 +02:00
localeiter ci: detect and prevent empty case statements in Go code (#11593) 2026-03-10 02:50:28 +01:00
mock.go Replace the 'relative-time' element scripting with custom, translatable rewrite (#6154) 2025-05-03 14:11:01 +00:00
plural_rules.go frontend: generic lazy loader for webcomponents (#8510) 2025-07-23 04:10:50 +02:00
plural_rules_test.go chore(test): separate and move around i18n testing (#10539) 2025-12-23 04:39:26 +01:00
translation.go fix(ui): hardcode sort options in search syntax hint, improve look (#11381) 2026-02-23 06:03:23 +01:00
translation_test.go chore(test): separate and move around i18n testing (#10539) 2025-12-23 04:39:26 +01:00