element-hq / element-hq/element-web
Could not fetch translation json for locale: 'de'
- Dominant language
- TypeScript
- Stars
- 13.5k
- Forks
- 2.8k
- PR merge metrics
- PR metrics pending
Description
### 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 `Settings` → `General` → `Language 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:
```txt
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 ()
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](https://github.com/matrix-org/matrix-react-sdk/tree/3bfb33fe488743f11b36e0357b4e81d40ff4ef16/src/i18n/strings) and [this](https://github.com/element-hq/element-web/tree/922f16812cc20931265e0ead524cbc7c4da9be10/src/i18n/strings) directory.
2. [Here](https://github.com/element-hq/element-web/blob/922f16812cc20931265e0ead524cbc7c4da9be10/scripts/copy-res.ts#L81), 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](https://github.com/element-hq/element-desktop/blob/69da4935b9d9cf30c82fef6d64ba75f8a3b5d943/src/language-helper.ts#L99), `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](https://github.com/element-hq/element-web/issues/32155)) until recently. I suspect [consolidating `de.json` into `de_DE.json`](https://github.com/element-hq/element-desktop/commit/a99b30f83929e7b6717ab67f74deecab02bcb48f) 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
Contributor guide
Assessment
This issue has not been assessed yet.