26 lines
859 B
JavaScript
26 lines
859 B
JavaScript
![]() |
const fs = require('fs').promises
|
||
|
|
||
|
// https://github.com/electron-userland/electron-builder/issues/4630
|
||
|
// https://github.com/electron-userland/electron-builder/issues/4630#issuecomment-782020139
|
||
|
|
||
|
module.exports = async(context) => {
|
||
|
const { electronPlatformName, appOutDir } = context
|
||
|
if (electronPlatformName !== 'darwin') return
|
||
|
const {
|
||
|
productFilename,
|
||
|
info: {
|
||
|
_metadata: { macLanguagesInfoPlistStrings },
|
||
|
},
|
||
|
} = context.packager.appInfo
|
||
|
|
||
|
const resPath = `${appOutDir}/${productFilename}.app/Contents/Resources`
|
||
|
|
||
|
// 创建APP语言包文件
|
||
|
return await Promise.all(
|
||
|
Object.entries(macLanguagesInfoPlistStrings).map(([lang, config]) => {
|
||
|
let infos = Object.entries(config).map(([k, v]) => `"${k}" = "${v}";`).join('\n')
|
||
|
return fs.writeFile(`${resPath}/${lang}.lproj/InfoPlist.strings`, infos)
|
||
|
}),
|
||
|
)
|
||
|
}
|