Skip to content

Commit

Permalink
fix: i18n of the main process (#237)
Browse files Browse the repository at this point in the history
**User-Facing Changes**
<!-- will be used as a changelog entry -->
fix i18n of the main process

**Description**
#227

- Remove duplicate i18next dependency from suite-desktop package
- Enable previously commented out i18n initialization code
- Import initI18n from suite-base package

<!-- link relevant GitHub issues -->
<!-- add `docs` label if this PR requires documentation updates -->
<!-- add relevant metric tracking for experimental / new features -->

**Checklist**

- [x] The web version was tested and it is running ok
- [x] The desktop version was tested and it is running ok
- [x] This change is covered by unit tests
  • Loading branch information
Woodii1998 authored Nov 4, 2024
1 parent a44b015 commit 9a57d1b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
3 changes: 3 additions & 0 deletions packages/suite-base/src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ export async function initI18n(options?: { context?: "browser" | "electron-main"
},
});
}

// ts-unused-exports:disable-next-line
export const sharedI18nObject = i18n;
1 change: 0 additions & 1 deletion packages/suite-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"eventemitter3": "5.0.1",
"fork-ts-checker-webpack-plugin": "9.0.2",
"html-webpack-plugin": "5.5.3",
"i18next": "23.5.1",
"jszip": "3.10.1",
"path-browserify": "1.0.1",
"plist": "3.1.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/suite-desktop/src/main/StudioWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import {
shell,
systemPreferences,
} from "electron";
import i18n, { t } from "i18next";
import path from "path";

import Logger from "@lichtblick/log";
import { APP_BAR_HEIGHT } from "@lichtblick/suite-base/src/components/AppBar/constants";
import { NativeAppMenuEvent } from "@lichtblick/suite-base/src/context/NativeAppMenuContext";
import { sharedI18nObject as i18n } from "@lichtblick/suite-base/src/i18n";
import { palette } from "@lichtblick/theme";

import StudioAppUpdater from "./StudioAppUpdater";
Expand All @@ -45,6 +45,8 @@ const rendererPath = MAIN_WINDOW_WEBPACK_ENTRY;
const closeMenuItem: MenuItemConstructorOptions = isMac ? { role: "close" } : { role: "quit" };
const log = Logger.getLogger(__filename);

const { t } = i18n;

function getWindowBackgroundColor(): string | undefined {
const theme = palette[nativeTheme.shouldUseDarkColors ? "dark" : "light"];
return theme.background?.default;
Expand Down
6 changes: 3 additions & 3 deletions packages/suite-desktop/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import { app, BrowserWindow, ipcMain, Menu, nativeTheme, session } from "electron";
import fs from "fs";
import i18n from "i18next";
import path from "path";

import Logger from "@lichtblick/log";
import { AppSetting } from "@lichtblick/suite-base/src/AppSetting";
import { initI18n, sharedI18nObject as i18n } from "@lichtblick/suite-base/src/i18n";

import StudioAppUpdater from "./StudioAppUpdater";
import StudioWindow from "./StudioWindow";
Expand Down Expand Up @@ -60,8 +60,8 @@ async function updateLanguage() {
}

export async function main(): Promise<void> {
// await initI18n({ context: "electron-main" });
// await updateLanguage();
await initI18n({ context: "electron-main" });
await updateLanguage();

// Allow integration tests to override the userData directory
const userDataOverride = process.argv.find((arg) => arg.startsWith("--user-data-dir="));
Expand Down
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3416,7 +3416,6 @@ __metadata:
eventemitter3: 5.0.1
fork-ts-checker-webpack-plugin: 9.0.2
html-webpack-plugin: 5.5.3
i18next: 23.5.1
jszip: 3.10.1
path-browserify: 1.0.1
plist: 3.1.0
Expand Down Expand Up @@ -12518,15 +12517,6 @@ __metadata:
languageName: node
linkType: hard

"i18next@npm:23.5.1":
version: 23.5.1
resolution: "i18next@npm:23.5.1"
dependencies:
"@babel/runtime": ^7.22.5
checksum: 4be043bd72287bfae9777a3252b9458d2e3f5e9a97ea62cf434e6e3767b45df4365d8780d0dd14efd4e9da5eb0f90534510b138f1372d1cb9012000a69bbedaf
languageName: node
linkType: hard

"i18next@npm:23.7.18":
version: 23.7.18
resolution: "i18next@npm:23.7.18"
Expand Down

0 comments on commit 9a57d1b

Please sign in to comment.