From 007410bb30b286baf416a2a7134ca56762e60ea8 Mon Sep 17 00:00:00 2001 From: Samuel Maddock Date: Sun, 15 Dec 2024 13:59:05 -0500 Subject: [PATCH] fix: prefer native chrome.i18n when available --- packages/electron-chrome-extensions/src/renderer/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/electron-chrome-extensions/src/renderer/index.ts b/packages/electron-chrome-extensions/src/renderer/index.ts index 21d2c4d0..8490a48c 100644 --- a/packages/electron-chrome-extensions/src/renderer/index.ts +++ b/packages/electron-chrome-extensions/src/renderer/index.ts @@ -329,10 +329,16 @@ export const injectExtensionAPIs = () => { }, i18n: { + shouldInject: () => manifest.manifest_version === 3, factory: (base) => { + // Electron configuration prevented this API from being available. + // https://github.com/electron/electron/pull/45031 + if (base.getMessage) { + return base + } + return { ...base, - // TODO(mv3): implement getUILanguage: () => 'en-US', getAcceptLanguages: (callback: any) => { const results = ['en-US']