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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not fetch translation json for locale: 'de' #1419

Open
Nils1729 opened this issue Jan 9, 2024 · 4 comments · May be fixed by #1493
Open

Could not fetch translation json for locale: 'de' #1419

Nils1729 opened this issue Jan 9, 2024 · 4 comments · May be fixed by #1493
Labels

Comments

@Nils1729
Copy link

Nils1729 commented Jan 9, 2024

Steps to reproduce

  1. Where are you starting? What can you see?
  • In Ubuntu settings, set my language to German
  • Install and launch Element Desktop
  • Log in, go to SettingsGeneralLanguage and region and select Deutsch (German)

Outcome

What did you expect?

Right-clicking the tray icon, the options are German.

What happened instead?

Right-clicking the tray icon, the options are still Show/Hide and Quit (not German). Web content is localized, though.

The logs show this error:

Changing application language to de
Fetching translation json for locale: de
Could not fetch translation json for locale: 'de' Error: Cannot find module './i18n/strings/de.json'
Require stack:
- /opt/Element/resources/app.asar/lib/language-helper.js
- /opt/Element/resources/app.asar/lib/tray.js
- /opt/Element/resources/app.asar/lib/settings.js
- /opt/Element/resources/app.asar/lib/ipc.js
- /opt/Element/resources/app.asar/lib/electron-main.js
- 
    at node:internal/modules/cjs/loader:1084:15
    at Function._resolveFilename (node:electron/js2c/browser_init:2:116646)
    at node:internal/modules/cjs/loader:929:27
    at Function._load (node:electron/js2c/asar_bundle:2:13327)
    at Module.require (node:internal/modules/cjs/loader:1150:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at AppLocalization.fetchTranslationJson (/opt/Element/resources/app.asar/lib/language-helper.js:86:20)
    at /opt/Element/resources/app.asar/lib/language-helper.js:99:39
    at Array.filter (<anonymous>)
    at AppLocalization.setAppLocale (/opt/Element/resources/app.asar/lib/language-helper.js:98:39) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/opt/Element/resources/app.asar/lib/language-helper.js',
    '/opt/Element/resources/app.asar/lib/tray.js',
    '/opt/Element/resources/app.asar/lib/settings.js',
    '/opt/Element/resources/app.asar/lib/ipc.js',
    '/opt/Element/resources/app.asar/lib/electron-main.js',
    undefined
  ]
}

So there is no de.json?

Probable cause

Digging into probable causes, I suspect the following chain of events:

  1. The language options are taken from the file names in this and this directory.
  2. Here, locales in the form xy_XY are shortened to xy. This only affects en_EN and de_DE.
  3. Element Desktop receives the locale via IPC.
  4. Here, en is hard-coded to be replaced by en_EN again. German locale is still de instead of de_DE.
  5. This probably caused no problem (as seen in successful loading of de in unrelated issues) until recently. I suspect consolidating de.json into de_DE.json caused loading of the file to fail as it was removed.

Potential fixes

  • Kind of ugly, but an additional hard-coded replacement from de to de_DE
  • Renaming de_DE.json to de.json in Element Desktop

Operating system

Ubuntu

Application version

Element version: 1.11.53 Crypto version: Olm 3.2.15

How did you install the app?

No response

Homeserver

No response

Will you send logs?

No

@Nils1729
Copy link
Author

I am willing to provide a PR for this. I think each of these changes could resolve the issue and would like to respect a maintainer's preferernce, or a different suggestions:

  • Renaming de_DE.json to de.json
  • Adding a replacement for de to de_DE, just like it is done with enen_EN

@t3chguy
Copy link
Member

t3chguy commented Jan 29, 2024

@Nils1729 option 1 isn't an option as Localazy would just overwrite your change, 2 would work but the correct solution would be to use something like normalizeLanguageKey in matrix-web-i18n to fallback to the general language file if the country specific one is unavailable.

@luxzeitlos
Copy link

This seems to crash the app on MacOS BigSur

@t3chguy
Copy link
Member

t3chguy commented Feb 29, 2024

BigSur is EOL so is not supported - https://github.com/element-hq/element-web#supported-environments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants