Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 3435f20

Browse files
committed
feat(forge): remove unused locales on macOS
1 parent 7427507 commit 3435f20

File tree

1 file changed

+38
-33
lines changed

1 file changed

+38
-33
lines changed

apps/desktop/electron-forge/forge.config.cjs

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -157,42 +157,47 @@ module.exports = {
157157
const extension = (isMac ? ".lproj" : ".pak");
158158

159159
for (const outputPath of packageResult.outputPaths) {
160-
const localesDir = isMac
161-
? path.join(outputPath, "TriliumNext Notes.app/Contents/Resources")
162-
: path.join(outputPath, 'locales');
163-
164-
if (!fs.existsSync(localesDir)) {
165-
console.log(`No locales directory found in '${localesDir}'.`);
166-
process.exit(2);
167-
}
168-
169-
const files = fs.readdirSync(localesDir);
170-
171-
for (const file of files) {
172-
if (!file.endsWith(extension)) {
173-
continue;
174-
}
175-
176-
let localeName = path.basename(file, extension);
177-
if (localeName === "en-US" && process.platform === "win32") {
178-
// If the locale is "en-US" on Windows, we treat it as "en".
179-
// This is because the Windows version of Electron uses "en-US.pak" instead of "en.pak".
180-
localeName = "en";
181-
}
160+
const localeDirs = isMac
161+
? [
162+
path.join(outputPath, "TriliumNext Notes.app/Contents/Resources"),
163+
path.join(outputPath, "TriliumNext Notes.app/Contents/Frameworks/Electron Framework.framework/Resources")
164+
]
165+
: [ path.join(outputPath, 'locales') ];
182166

183-
if (localesToKeep.includes(localeName)) {
184-
keptLocales.add(localeName);
185-
continue;
167+
for (const localeDir of localeDirs) {
168+
if (!fs.existsSync(localeDir)) {
169+
console.log(`No locales directory found in '${localeDir}'.`);
170+
process.exit(2);
186171
}
187-
188-
const filePath = path.join(localesDir, file);
189-
if (isMac) {
190-
fs.rm(filePath, { recursive: true });
191-
} else {
192-
fs.unlinkSync(filePath);
172+
173+
const files = fs.readdirSync(localeDir);
174+
175+
for (const file of files) {
176+
if (!file.endsWith(extension)) {
177+
continue;
178+
}
179+
180+
let localeName = path.basename(file, extension);
181+
if (localeName === "en-US" && process.platform === "win32") {
182+
// If the locale is "en-US" on Windows, we treat it as "en".
183+
// This is because the Windows version of Electron uses "en-US.pak" instead of "en.pak".
184+
localeName = "en";
185+
}
186+
187+
if (localesToKeep.includes(localeName)) {
188+
keptLocales.add(localeName);
189+
continue;
190+
}
191+
192+
const filePath = path.join(localeDir, file);
193+
if (isMac) {
194+
fs.rm(filePath, { recursive: true });
195+
} else {
196+
fs.unlinkSync(filePath);
197+
}
198+
199+
removedLocales.push(file);
193200
}
194-
195-
removedLocales.push(file);
196201
}
197202
}
198203

0 commit comments

Comments
 (0)