-
Notifications
You must be signed in to change notification settings - Fork 62
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
Showing
3 changed files
with
87 additions
and
9 deletions.
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
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,56 @@ | ||
const { spawn } = require('child_process'); | ||
const path = require('path'); | ||
|
||
const translations = [ | ||
{ locale: 'fr_FR' }, | ||
{ locale: 'ja_JP' }, | ||
{ locale: 'nl' }, | ||
{ locale: 'ru_RU' }, | ||
{ locale: 'zh_CN' } | ||
]; | ||
|
||
async function buildTranslation(locale) { | ||
const baseDir = path.join('nbclassic', 'i18n', locale, 'LC_MESSAGES'); | ||
const poFile = path.join(baseDir, 'nbjs.po'); | ||
const jsonFile = path.join(baseDir, 'nbjs.json'); | ||
|
||
return new Promise((resolve, reject) => { | ||
const process = spawn('po2json', [ | ||
'-p', // pretty print | ||
'-F', // force overwrite | ||
'-f', 'jed1.x', // format | ||
'-d', 'nbjs', // domain | ||
poFile, | ||
jsonFile | ||
]); | ||
|
||
process.stdout.on('data', (data) => { | ||
console.log(`${locale}: ${data}`); | ||
}); | ||
|
||
process.stderr.on('data', (data) => { | ||
console.error(`${locale} error: ${data}`); | ||
}); | ||
|
||
process.on('close', (code) => { | ||
if (code === 0) { | ||
console.log(`✓ Built translation for ${locale}`); | ||
resolve(); | ||
} else { | ||
reject(new Error(`Failed to build translation for ${locale}`)); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
async function buildAllTranslations() { | ||
try { | ||
await Promise.all(translations.map(({ locale }) => buildTranslation(locale))); | ||
console.log('All translations built successfully!'); | ||
} catch (error) { | ||
console.error('Error building translations:', error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
buildAllTranslations(); |
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,28 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const sourceFile = path.join('nbclassic', 'static', 'components', 'marked', 'lib', 'marked.umd.js'); | ||
const destFile = path.join('nbclassic', 'static', 'components', 'marked', 'lib', 'marked.js'); | ||
|
||
// Check file existence | ||
const sourceExists = fs.existsSync(sourceFile); | ||
const destExists = fs.existsSync(destFile); | ||
|
||
if (!sourceExists && !destExists) { | ||
// Both files missing - critical error | ||
console.error(`Error: ${destFile} is required but cannot be created (${sourceFile} not found)`); | ||
process.exit(1); | ||
} else if (!sourceExists) { | ||
// Source missing but dest exists - skip copy | ||
console.log(`Copy skipped: ${sourceFile} not found (using existing ${destFile})`); | ||
process.exit(0); | ||
} | ||
|
||
// Source exists, attempt copy | ||
try { | ||
fs.copyFileSync(sourceFile, destFile); | ||
console.log(`Successfully copied ${sourceFile} to ${destFile}`); | ||
} catch (err) { | ||
console.error(`Error copying file: ${err.message}`); | ||
process.exit(1); | ||
} |