Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing translation in web app #730

Closed
codebude opened this issue May 15, 2023 · 4 comments
Closed

Missing translation in web app #730

codebude opened this issue May 15, 2023 · 4 comments
Labels
馃 bug Something isn't working

Comments

@codebude
Copy link

codebude commented May 15, 2023

馃悶 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.
@codebude codebude added the 馃 bug Something isn't working label May 15, 2023
@binwiederhier
Copy link
Owner

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).

@codebude
Copy link
Author

codebude commented 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:

language: i18n.language,

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"]
})

@binwiederhier
Copy link
Owner

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 f998d4d

Thanks for reporting, and for the solution!

@codebude
Copy link
Author

You're welcome...
...und viele Gr眉脽e aus der Heimat. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
馃 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants