Skip to content

Commit

Permalink
completed the translation script function.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengyangliu committed Jun 18, 2024
1 parent 85588d8 commit af586a3
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 285 deletions.
6 changes: 3 additions & 3 deletions script/i18n/extract-format-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const searchExtensionsFormatMessages = (err, pathName, dirent) => {
const containsDeviceRegister = fs.readFileSync(pathName, 'utf8').slice(0, 100)
.match(/registerDevice/g);

if (path.basename(pathName) === EXTENSIONS_FILE || containsDeviceRegister) {
if ((path.basename(pathName) === EXTENSIONS_FILE) || containsDeviceRegister) {
if (isOfficial(pathName)) {
const content = fs.readFileSync(pathName, 'utf8');
const matchedContent = content.match(/formatMessage\({([\s\S]*?)}\)/g);
Expand Down Expand Up @@ -218,7 +218,7 @@ generateInterfaceMessageJson(workDir)
const filePath = path.resolve(workDir, 'translations/extensions/en.json');
fs.ensureDirSync(path.dirname(filePath));
fs.writeFileSync(filePath, extensionJson);
console.log(`Interface i18n is created: ${filePath}`);
console.log(`Scrartch extensions i18n is created: ${filePath}`);
})
.then(() => generateBlocksMessageJson(workDir))
.then(blocksJson => {
Expand All @@ -228,5 +228,5 @@ generateInterfaceMessageJson(workDir)
console.log(`Blocks i18n is created: ${filePath}`);
})
.then(() => {
console.log('Complete translate proccess');
console.log('Complete extract proccess');
});
9 changes: 4 additions & 5 deletions script/i18n/push-format-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ const runCliSync = cmd => {
}
};

const txPushSrc = path.resolve(__dirname, '../node_modules/openblock-l10n/scripts/tx-push-src.js');
const pushBlocksContent = `node ${txPushSrc} openblock-resources blocks ${path.resolve(workDir)}/translations/blocks/en.json`; // eslint-disable-line max-len
const pushInterfaceContent = `node ${txPushSrc} openblock-resources interface ${path.resolve(workDir)}/translations/interface/en.json`; // eslint-disable-line max-len
const pushExtensionsContent = `node ${txPushSrc} openblock-resources extensions ${path.resolve(workDir)}/translations/extensions/en.json`; // eslint-disable-line max-len
const pushBlocksContent = `tx-push-src openblock-resources blocks ${path.resolve(workDir)}/translations/blocks/en.json`; // eslint-disable-line max-len
const pushInterfaceContent = `tx-push-src openblock-resources interface ${path.resolve(workDir)}/translations/interface/en.json`; // eslint-disable-line max-len
const pushExtensionsContent = `tx-push-src openblock-resources extensions ${path.resolve(workDir)}/translations/extensions/en.json`; // eslint-disable-line max-len

runCliSync(pushBlocksContent);
runCliSync(pushInterfaceContent);
runCliSync(pushExtensionsContent);

if (exitCode === 0) {
console.log('\nSuccessfully pushed to transifex');
console.log('Successfully push i18n to transifex');
}
204 changes: 0 additions & 204 deletions script/i18n/update-third-party-translations.js

This file was deleted.

Loading

0 comments on commit af586a3

Please sign in to comment.