-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
891e72a
commit 65e107f
Showing
2 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
// Copyright 2021 Signal Messenger, LLC | ||
// Copyright 2021-2022 Signal Messenger, LLC | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
import type { AfterPackContext } from 'electron-builder'; | ||
import { afterPack as fuseElectron } from './fuse-electron'; | ||
import { afterPack as mergeASARs } from './merge-macos-asars'; | ||
import { afterPack as copyPacks } from './copy-language-packs'; | ||
|
||
export async function afterPack(context: AfterPackContext): Promise<void> { | ||
await mergeASARs(context); | ||
await fuseElectron(context); | ||
await copyPacks(context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright 2022 Signal Messenger, LLC | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
import fse from 'fs-extra'; | ||
import path from 'path'; | ||
import type { AfterPackContext } from 'electron-builder'; | ||
|
||
export async function afterPack({ | ||
appOutDir, | ||
packager, | ||
electronPlatformName, | ||
}: AfterPackContext): Promise<void> { | ||
let defaultLocale: string; | ||
let ourLocales = await fse.readdir( | ||
path.join(__dirname, '..', '..', '_locales') | ||
); | ||
|
||
let localesPath: string; | ||
if (electronPlatformName === 'darwin') { | ||
const { productFilename } = packager.appInfo; | ||
|
||
// en.lproj/locale.pak | ||
// zh_CN.lproj/locale.pak | ||
defaultLocale = 'en.lproj'; | ||
ourLocales = ourLocales.map(locale => `${locale}.lproj`); | ||
|
||
localesPath = path.join( | ||
appOutDir, | ||
`${productFilename}.app`, | ||
'Contents', | ||
'Frameworks', | ||
This comment has been minimized.
Sorry, something went wrong. |
||
'Electron Framework.framework', | ||
'Resources' | ||
); | ||
} else if ( | ||
electronPlatformName === 'linux' || | ||
electronPlatformName === 'win32' | ||
) { | ||
// Shared between windows and linux | ||
defaultLocale = 'en-US.pak'; | ||
ourLocales = ourLocales.map(locale => { | ||
if (locale === 'en') { | ||
return defaultLocale; | ||
} | ||
|
||
return `${locale.replace(/_/g, '-')}.pak`; | ||
}); | ||
|
||
localesPath = path.join(appOutDir, 'locales'); | ||
} else { | ||
console.error( | ||
`Unsupported platform: ${electronPlatformName}, not copying pak files` | ||
); | ||
return; | ||
} | ||
|
||
const electronLocales = new Set(await fse.readdir(localesPath)); | ||
const promises = new Array<Promise<void>>(); | ||
for (const locale of ourLocales) { | ||
if (electronLocales.has(locale)) { | ||
continue; | ||
} | ||
|
||
console.log(`Copying ${defaultLocale} to ${locale}`); | ||
promises.push( | ||
fse.copy( | ||
path.join(localesPath, defaultLocale), | ||
path.join(localesPath, locale) | ||
) | ||
); | ||
} | ||
|
||
await Promise.all(promises); | ||
} |
Lines 31 and 32 need removing to make this work on Macs