element-desktop
element-desktop copied to clipboard
Could not fetch translation json for locale: 'de'
Steps to reproduce
- 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
Settings
→General
→Language and region
and selectDeutsch
(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:
- The language options are taken from the file names in this and this directory.
-
Here, locales in the form
xy_XY
are shortened toxy
. This only affectsen_EN
andde_DE
. - Element Desktop receives the locale via IPC.
-
Here,
en
is hard-coded to be replaced byen_EN
again. German locale is stillde
instead ofde_DE
. - This probably caused no problem (as seen in successful loading of
de
in unrelated issues) until recently. I suspect consolidatingde.json
intode_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
tode_DE
- Renaming
de_DE.json
tode.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
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
tode.json
- [ ] Adding a replacement for
de
tode_DE
, just like it is done withen
→en_EN
@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.
This seems to crash the app on MacOS BigSur
BigSur is EOL so is not supported - https://github.com/element-hq/element-web#supported-environments
I just started experiencing this issue on OpenSUSE Tumbleweed:
No update_base_url is defined: auto update is disabled
Fetching translation json for locale: en_EN
Changing application language to de
Fetching translation json for locale: de
Could not fetch translation json for locale: 'de' Error: ENOENT: no such file or directory, open '/usr/share/element/app/lib/i18n/strings/de.json'
at Object.readFileUtf8 (node:internal/fs/sync:25:18)
at Object.readFileSync (node:fs:441:19)
at t.readFileSync (node:electron/js2c/node_init:2:9771)
at loadJsonFile (/usr/share/element/app/lib/utils.js:55:36)
at AppLocalization.fetchTranslationJson (/usr/share/element/app/lib/language-helper.js:83:45)
at /usr/share/element/app/lib/language-helper.js:96:39
at Array.filter (<anonymous>)
at AppLocalization.setAppLocale (/usr/share/element/app/lib/language-helper.js:95:39)
at new AppLocalization (/usr/share/element/app/lib/language-helper.js:65:18)
at /usr/share/element/app/lib/electron-main.js:530:30 {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/usr/share/element/app/lib/i18n/strings/de.json'
}
Resetting the UI components after locale change
Resetting the UI components after locale change
(node:10295) electron: Failed to load URL: vector://vector/webapp/ with error: ERR_FILE_NOT_FOUND
(Use `electron --trace-warnings ...` to show where the warning was created)
[10332:0705/120921.278141:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!
Version:
S | Name | Type | Version | Arch | Repository
---+-----------------+---------+-------------+--------+----------------------
i+ | element-desktop | package | 1.11.69-2.1 | x86_64 | Main Repository (OSS)
element-desktop
is looking for de.json
, but de_DE.json
exists:
I tried adjusting ~/.config/Element/electron-config.json
to:
{
"locale": [
"de_DE"
]
}
(was "de"
before)
This causes the above error to no longer surface, but it does not make element-desktop
start fully:
The state in the screenshot is stable. Nothing changes afterwards.
Neither does removing ~/.config/Element/electron-config.json
altogether allow element-desktop
to start successfully: