mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-06-13 21:50:52 -04:00
Adding scratch-l10n dependency
* Added .tx configuation to be able to send source strings to transifex * added dependency on scratch-l10n 2.x, and removed everything related to generating the l10n messages locally * updated playground intl reducer to use paint messages from l10n package
This commit is contained in:
parent
09ef88cac1
commit
ced3563fda
5 changed files with 17 additions and 86 deletions
scripts
|
@ -1,67 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/*
|
||||
Generates locale/messages.json from current translastion files
|
||||
|
||||
Translations are expected to be in the ./translations directory.
|
||||
Translation files are in Chrome i18n json format:
|
||||
'''
|
||||
{
|
||||
"message.id": {
|
||||
"message": "The translated text",
|
||||
"description": "Tips for translators"
|
||||
},
|
||||
...
|
||||
}
|
||||
'''
|
||||
They are named by locale, for example: 'fr.json' or 'zh-cn.json'
|
||||
|
||||
Current languages supported are listed in ../src/languages.json
|
||||
|
||||
Converts the collection of translation files to a single set of messages.
|
||||
Example output:
|
||||
'''
|
||||
{
|
||||
"en": {
|
||||
"action.addBackdrop": "Add Backdrop",
|
||||
"action.addCostume": "Add Costume",
|
||||
"action.recordSound": "Record Sound",
|
||||
"action.addSound": "Add Sound"
|
||||
},
|
||||
"fr": {
|
||||
"action.addSound": "Ajouter Son",
|
||||
"action.addCostume": "Ajouter Costume",
|
||||
"action.addBackdrop": "Ajouter Arrière-plan",
|
||||
"action.recordSound": "Enregistrement du Son"
|
||||
}
|
||||
}
|
||||
'''
|
||||
|
||||
Missing locales are ignored, react-intl will use the default messages for them.
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const mkdirp = require('mkdirp');
|
||||
|
||||
const locales = ['en'];
|
||||
const LANG_DIR = './translations/';
|
||||
const MSGS_DIR = './locale/';
|
||||
|
||||
let messages = locales.reduce((collection, lang) => {
|
||||
let langMessages = {};
|
||||
try {
|
||||
let langData = JSON.parse(
|
||||
fs.readFileSync(path.resolve(LANG_DIR, lang + '.json'), 'utf8')
|
||||
);
|
||||
Object.keys(langData).forEach((id) => {
|
||||
langMessages[id] = langData[id].message;
|
||||
});
|
||||
collection[lang] = langMessages;
|
||||
} catch (e) {
|
||||
process.stdout.write(lang + ' translation file missing, will use defaults.\n');
|
||||
}
|
||||
return collection;
|
||||
}, {});
|
||||
|
||||
mkdirp.sync(MSGS_DIR);
|
||||
fs.writeFileSync(MSGS_DIR + 'messages.json', JSON.stringify(messages, null, 2));
|
Loading…
Add table
Add a link
Reference in a new issue