Closed tonytony2020 closed 1 year ago
ref https://developer.chrome.com/docs/webstore/i18n/
related rollup plugin snippet:
const pathManifestAbs = path.normalize(pathManifest); const pathParent = path.dirname(pathManifestAbs); const pathRoot = path.dirname(path.dirname(pathManifestAbs)); const manifest = fs.readFileSync(pathManifestAbs, { encoding: "utf8" }) const manifestContent: chrome.runtime.ManifestV3 = JSON.parse(manifest); // .... async generateBundle(options: NormalizedOutputOptions, bundle: OutputBundle, isWrite: boolean) { console.log({ default_locale: manifestContent.default_locale }) if (manifestContent.default_locale) { const src = path.resolve(pathParent, "_locales") const pathLocaleMessagesJson = path.resolve(src, manifestContent.default_locale, "messages.json") if (!fs.existsSync(pathLocaleMessagesJson)) { console.warn(`locale file ${pathLocaleMessagesJson} not found`) } const dest = path.resolve(config.build.outDir, "_locales") console.info(`copy _locales ${src} => ${dest}`) fs.cpSync(src, dest, { recursive: true }); } // .... }
This feature is already supported in v1.0.4.
ref https://developer.chrome.com/docs/webstore/i18n/
related rollup plugin snippet: