|
|
|
@ -157,42 +157,47 @@ module.exports = {
|
|
|
|
const extension = (isMac ? ".lproj" : ".pak");
|
|
|
|
const extension = (isMac ? ".lproj" : ".pak");
|
|
|
|
|
|
|
|
|
|
|
|
for (const outputPath of packageResult.outputPaths) {
|
|
|
|
for (const outputPath of packageResult.outputPaths) {
|
|
|
|
const localesDir = isMac
|
|
|
|
const localeDirs = isMac
|
|
|
|
? path.join(outputPath, "TriliumNext Notes.app/Contents/Resources")
|
|
|
|
? [
|
|
|
|
: path.join(outputPath, 'locales');
|
|
|
|
path.join(outputPath, "TriliumNext Notes.app/Contents/Resources"),
|
|
|
|
|
|
|
|
path.join(outputPath, "TriliumNext Notes.app/Contents/Frameworks/Electron Framework.framework/Resources")
|
|
|
|
if (!fs.existsSync(localesDir)) {
|
|
|
|
]
|
|
|
|
console.log(`No locales directory found in '${localesDir}'.`);
|
|
|
|
: [ path.join(outputPath, 'locales') ];
|
|
|
|
process.exit(2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const files = fs.readdirSync(localesDir);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const file of files) {
|
|
|
|
|
|
|
|
if (!file.endsWith(extension)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let localeName = path.basename(file, extension);
|
|
|
|
|
|
|
|
if (localeName === "en-US" && process.platform === "win32") {
|
|
|
|
|
|
|
|
// If the locale is "en-US" on Windows, we treat it as "en".
|
|
|
|
|
|
|
|
// This is because the Windows version of Electron uses "en-US.pak" instead of "en.pak".
|
|
|
|
|
|
|
|
localeName = "en";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (localesToKeep.includes(localeName)) {
|
|
|
|
for (const localeDir of localeDirs) {
|
|
|
|
keptLocales.add(localeName);
|
|
|
|
if (!fs.existsSync(localeDir)) {
|
|
|
|
continue;
|
|
|
|
console.log(`No locales directory found in '${localeDir}'.`);
|
|
|
|
|
|
|
|
process.exit(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const filePath = path.join(localesDir, file);
|
|
|
|
const files = fs.readdirSync(localeDir);
|
|
|
|
if (isMac) {
|
|
|
|
|
|
|
|
fs.rm(filePath, { recursive: true });
|
|
|
|
for (const file of files) {
|
|
|
|
} else {
|
|
|
|
if (!file.endsWith(extension)) {
|
|
|
|
fs.unlinkSync(filePath);
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let localeName = path.basename(file, extension);
|
|
|
|
|
|
|
|
if (localeName === "en-US" && process.platform === "win32") {
|
|
|
|
|
|
|
|
// If the locale is "en-US" on Windows, we treat it as "en".
|
|
|
|
|
|
|
|
// This is because the Windows version of Electron uses "en-US.pak" instead of "en.pak".
|
|
|
|
|
|
|
|
localeName = "en";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (localesToKeep.includes(localeName)) {
|
|
|
|
|
|
|
|
keptLocales.add(localeName);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const filePath = path.join(localeDir, file);
|
|
|
|
|
|
|
|
if (isMac) {
|
|
|
|
|
|
|
|
fs.rm(filePath, { recursive: true });
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fs.unlinkSync(filePath);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
removedLocales.push(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
removedLocales.push(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|