element-desktop
element-desktop copied to clipboard
Fix Could not fetch translation json for locale: 'de'
Fixes #1419.
Checklist
- [x] Ensure your code works with manual testing
- [ ] Linter and other CI checks pass
- [x] Sign-off given on the changes (see CONTRIBUTING.md)
In implementation it turned out that it was the opposite problem than in the comment: There is no generic de
, only the specific de_DE
. I tried to cover this case as generically as possible, although it only occurs with en
and de
at the time of writing.
Type: defect
I am not really happy with the amount of logging, as every locale that cannot be found produces a stack trace like this:
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:96:20)
at /opt/Element/resources/app.asar/lib/language-helper.js:109:39
at Array.filter (<anonymous>)
at AppLocalization.setAppLocale (/opt/Element/resources/app.asar/lib/language-helper.js:108:86) {
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
]
}
Fetching translation json for locale: de_DE
Resetting the UI components after locale change
This only affects en
and de
. But a stack every time Element launches with one of these locales clutters the journal with non-errors. On the other hand, these missing locales might be errors sometimes. To the reviewer: Is just logging everything acceptable? What are the alternatives?
Drafting this because it is not critical and seems rather complex. I'll come back once I have some more time at hand.