File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 122122 "owner" : " gitify-app" ,
123123 "repo" : " gitify"
124124 },
125- "afterSign" : " scripts/notarize.js"
125+ "afterSign" : " scripts/notarize.js" ,
126+ "afterPack" : " scripts/remove-unused-locales.js"
126127 },
127128 "dependencies" : {
128129 "@electron/remote" : " 2.1.2" ,
Original file line number Diff line number Diff line change 1+ const path = require ( 'node:path' ) ;
2+ const fs = require ( 'node:fs' ) ;
3+
4+ const packageJson = require ( '../package.json' ) ;
5+ const electronLanguages = packageJson . build . electronLanguages ;
6+
7+ exports . default = async ( context ) => {
8+ const appName = context . packager . appInfo . productFilename ;
9+ const appOutDir = context . appOutDir ;
10+ const platform = context . electronPlatformName ;
11+
12+ if ( platform !== 'darwin' ) {
13+ return ;
14+ }
15+
16+ const resourcesPath = path . join (
17+ appOutDir ,
18+ `${ appName } .app` ,
19+ 'Contents' ,
20+ 'Frameworks' ,
21+ 'Electron Framework.framework' ,
22+ 'Versions' ,
23+ 'A' ,
24+ 'Resources' ,
25+ ) ;
26+
27+ // Get all locale directories
28+ const allLocales = fs
29+ . readdirSync ( resourcesPath )
30+ . filter ( ( file ) => file . endsWith ( '.lproj' ) ) ;
31+
32+ const langLocales = electronLanguages . map ( ( lang ) => `${ lang } .lproj` ) ;
33+
34+ // Remove unused locales
35+ for ( const locale of allLocales ) {
36+ if ( ! langLocales . includes ( locale ) ) {
37+ const localePath = path . join ( resourcesPath , locale ) ;
38+ fs . rmSync ( localePath , { recursive : true } ) ;
39+ }
40+ }
41+ } ;
You can’t perform that action at this time.
0 commit comments