[GH-ISSUE #730] Missing translation in web app #534

Closed
opened 2026-05-07 00:25:11 +02:00 by BreizhHardware · 4 comments

Originally created by @codebude on GitHub (May 15, 2023).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/730

🐞 Describe the bug
In the web app, there's a part (Account -> Attachment storage -> subheading) which doesn't seem connected to the localization engine. I use the German UI, but the text is still English. Weblate says, that all texts (100%) are translated for German. Thus I assume, that the part isn't linked correctly with the "translation engine".

It is this text: https://hosted.weblate.org/translate/ntfy/web/de/?q=expiry&sort_by=-priority%2Cposition&checksum=

💻 Components impacted

  • web app

💡 Screenshots and/or logs
image

🔮 Additional context

  • It seems that only the {expiry} part isn't translated correctly.
  • This bug occurs only, if a user hasn't set a specifc language in his/her account settings (=language selector box in settings is empty). As soon, as one sets the language explicitly (Settings -> Appearrance -> Language) to German, even the {expiry} part is translated correctly.
Originally created by @codebude on GitHub (May 15, 2023). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/730 :lady_beetle: **Describe the bug** In the web app, there's a part (Account -> Attachment storage -> subheading) which doesn't seem connected to the localization engine. I use the German UI, but the text is still English. Weblate says, that all texts (100%) are translated for German. Thus I assume, that the part isn't linked correctly with the "translation engine". It is this text: https://hosted.weblate.org/translate/ntfy/web/de/?q=expiry&sort_by=-priority%2Cposition&checksum= :computer: **Components impacted** - web app :bulb: **Screenshots and/or logs** ![image](https://github.com/binwiederhier/ntfy/assets/2236234/ba695284-bf41-4aae-b68a-e223b8d07a60) :crystal_ball: **Additional context** - It seems that only the `{expiry}` part isn't translated correctly. - This bug occurs only, if a user hasn't set a specifc language in his/her account settings (=language selector box in settings is empty). As soon, as one sets the language explicitly (Settings -> Appearrance -> Language) to German, even the `{expiry}` part is translated correctly.
BreizhHardware 2026-05-07 00:25:11 +02:00
  • closed this issue
  • added the
    🪲 bug
    label
Author
Owner

@binwiederhier commented on GitHub (May 15, 2023):

I looked at this briefly, thinking it was going to be an easy fix, but it turns out that I think I may have messed up some of the i18n stuff, or at least I'm not understanding it well enough. I believe your locale is set as de-DE or de-AT or similar, and my language files are only called de.json. The same problem exists with English and en-US, etc.

Long story short, it's not loading the correct language because i18n.language is set to de-DE instead of de. The language detection stuff apparently does fall back from de-DE to de, but I don't know how to get to that variable (yet).

<!-- gh-comment-id:1548323075 --> @binwiederhier commented on GitHub (May 15, 2023): I looked at this briefly, thinking it was going to be an easy fix, but it turns out that I think I may have messed up some of the i18n stuff, or at least I'm not understanding it well enough. I believe your locale is set as `de-DE` or `de-AT` or similar, and my language files are only called `de.json`. The same problem exists with English and `en-US`, etc. Long story short, it's not loading the correct language because `i18n.language` is set to `de-DE` instead of `de`. The language detection stuff apparently does fall back from `de-DE` to `de`, but I don't know how to get to that variable (yet).
Author
Owner

@codebude commented on GitHub (May 15, 2023):

Thanks for investigating the error. I also tried to understand what is happening, but I'm not sure I got it.
I think the problem is this part here:
github.com/binwiederhier/ntfy@04b7b4284a/web/src/components/Account.js (L393)
The i18n.language seems to be incorrect here. As far as I understand, humanizeDuration expects the code of the translation file (in your case two-letter, e.g.) but i18n.language contains the detected code (de-DE). That's in general/for i18next no problem, because it knows that it should fallback from de-DE to de, but as far as I can see, the humanize-duration module doesn't.

If I read the i18n documentation correct, than i18n.resolvedLanguage should work here.
So rewriting the Account.js code to the following might be a solution:

expiry: humanizeDuration(account.limits.attachment_expiry_duration * 1000, {
    language: i18n.resolvedLanguage,
    fallbacks: ["en"]
})
<!-- gh-comment-id:1548613247 --> @codebude commented on GitHub (May 15, 2023): Thanks for investigating the error. I also tried to understand what is happening, but I'm not sure I got it. I think the problem is this part here: https://github.com/binwiederhier/ntfy/blob/04b7b4284abac53205ec5bb3be006d07f529b661/web/src/components/Account.js#L393 The `i18n.language` seems to be incorrect here. As far as I understand, humanizeDuration expects the code of the translation file (in your case two-letter, e.g.) but `i18n.language` contains the detected code (`de-DE`). That's in general/for i18next no problem, because it knows that it should fallback from de-DE to de, but as far as I can see, the humanize-duration module doesn't. If I read the i18n documentation correct, than `i18n.resolvedLanguage` should work here. So rewriting the Account.js code to the following might be a solution: ```` javascript expiry: humanizeDuration(account.limits.attachment_expiry_duration * 1000, { language: i18n.resolvedLanguage, fallbacks: ["en"] })
Author
Owner

@binwiederhier commented on GitHub (May 15, 2023):

Oh maaaan, I should have read your comment first. Because you solved it the same way I eventually did, except that I did my own research when I didn't have to. Good thing we came to the same conclusion.

Fixed in github.com/binwiederhier/ntfy@f998d4d2ad

Thanks for reporting, and for the solution!

<!-- gh-comment-id:1548765337 --> @binwiederhier commented on GitHub (May 15, 2023): Oh maaaan, I should have read your comment first. Because you solved it the same way I eventually did, except that I did my own research when I didn't have to. Good thing we came to the same conclusion. Fixed in https://github.com/binwiederhier/ntfy/commit/f998d4d2adc4f582035eb37cf0537eb2d0b1e272 Thanks for reporting, and for the solution!
Author
Owner

@codebude commented on GitHub (May 16, 2023):

You're welcome...
...und viele Grüße aus der Heimat. ;-)

<!-- gh-comment-id:1548971566 --> @codebude commented on GitHub (May 16, 2023): You're welcome... ...und viele Grüße aus der Heimat. ;-)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#534
No description provided.