mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-12-18 03:27:02 -05:00
9e4ef5fb1b
* Transifex transition Scripts and configuration for transition to Transifex for translation. * Transifex transition update changed the name of the place where translations are saved from ‘translations’ to localizations so that we can have a consistent name in both scratchr2, and scratch-www. A couple of other little clean-ups to make sure that it’s ES5 compliant. - don’t use const - don’t use template strings (backticks)
51 lines
1.4 KiB
JavaScript
Executable file
51 lines
1.4 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
/*
|
|
Generate language json files corresponding to l10n files to import from
|
|
pootle into transifex.
|
|
|
|
For example, extract the strings corresponding to splash ids from pootle.
|
|
For each language, in localizations/splash create
|
|
fr.json =>
|
|
{
|
|
'splash.welcome' : 'Bienvenue',
|
|
...
|
|
}
|
|
etc.
|
|
*/
|
|
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
var routes = require('../src/routes.json');
|
|
var languages = require('../languages.json');
|
|
var localeCompare = require('./lib/locale-compare');
|
|
|
|
var outputDir = path.resolve(__dirname, '../localizations');
|
|
try {
|
|
fs.accessSync(outputDir, fs.F_OK);
|
|
} catch (err) {
|
|
// Doesn't exist - create it.
|
|
fs.mkdirSync(outputDir);
|
|
}
|
|
|
|
// general is a special case, do it first
|
|
var l10n = path.resolve(__dirname, '../src/l10n.json');
|
|
localeCompare.writeTranslations('general', l10n, languages);
|
|
|
|
for (var v in routes) {
|
|
if (typeof routes[v].redirect !== 'undefined') {
|
|
continue;
|
|
}
|
|
var subdir = routes[v].view.split('/');
|
|
subdir.pop();
|
|
l10n = path.resolve(__dirname, '../src/views/' + subdir.join('/') + '/l10n.json');
|
|
var name = routes[v].name;
|
|
try {
|
|
// only import if there is an l10n file
|
|
fs.accessSync(l10n);
|
|
} catch (err) {
|
|
// skip views without l10n files
|
|
process.stdout.write(`Skipping ${name}, no l10n\n`);
|
|
continue;
|
|
}
|
|
localeCompare.writeTranslations(name, l10n, languages);
|
|
}
|