diff --git a/.gitignore b/.gitignore index 476cb5a20..0eed05504 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,6 @@ npm-* # Locales /locales /intl -/localizations - # Elastic Beanstalk Files .elasticbeanstalk/* diff --git a/Makefile b/Makefile index c8a86a2f6..892e252d1 100644 --- a/Makefile +++ b/Makefile @@ -24,8 +24,7 @@ deploy: @make sync translations: - ./bin/tx-import localizations - ./bin/build-locales localizations intl + ./bin/build-locales node_modules/scratchr2_translations/www/translations intl webpack: $(WEBPACK) --bail diff --git a/bin/build-locales b/bin/build-locales index 23e496153..66d8ca9f2 100755 --- a/bin/build-locales +++ b/bin/build-locales @@ -97,7 +97,13 @@ var globalTemplateFile = path.resolve(__dirname, '../src/l10n.json'); var generalLocales = {'en': JSON.parse(fs.readFileSync(globalTemplateFile, 'utf8'))}; for ( var l in languages ) { try { - var langTranslations = path.resolve(__dirname, '../', localesDir, 'general', l + '.json'); + var langTranslations = path.resolve( + __dirname, + '../', + localesDir, + 'scratch-website.general-l10njson', + l + '.json' + ); fs.accessSync(langTranslations); generalLocales[l] = JSON.parse(fs.readFileSync(langTranslations, 'utf8')); } catch (err) { @@ -187,7 +193,13 @@ async.forEachLimit(views, 5, function (view, cb) { // merge view specific english strings, first then other languages process.stdout.write('Merging translations for ' + view + '\n'); async.forEach(allLangs, function (isoCode, cb) { - var translationsFile = path.resolve(__dirname, '../', localesDir, view, isoCode + '.json'); + var translationsFile = path.resolve( + __dirname, + '../', + localesDir, + 'scratch-website.' + view + '-l10njson', + isoCode + '.json' + ); fs.readFile(translationsFile, 'utf8', function (err, data) { if (err) { if (err.code === 'ENOENT') { diff --git a/bin/tx-import b/bin/tx-import deleted file mode 100755 index 091833cee..000000000 --- a/bin/tx-import +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env node - -/* - Downloads translation json files from Transifex for all the languages defined - in the menus. Expects a Transifex API key to be set in the TX_TOKEN environment - variable. Takes as input a directory in which to store the translations. - - Creates subdirectories for each view and 'general'. Creates .json files - for each language downloaded. Uses the english source l10n file if there is - an error. -*/ -var fs = require('fs'); -var path = require('path'); -var async = require('async'); -var Transifex = require('transifex'); -var languages = require('../languages.json'); -var routes = require('../src/routes.json'); - - -// ----------------------------------------------------------------------------- -// Main script -// ----------------------------------------------------------------------------- - - -var args = process.argv.slice(2); - -if (!args.length) { - process.stdout.write('A destination directory for localizations must be specified.'); - process.exit(1); -} - -var outputDir = path.resolve(__dirname, '../', args.shift()); -try { - fs.accessSync(outputDir, fs.F_OK); -} catch (err) { - // Doesn't exist - create it. - fs.mkdirSync(outputDir); -} - -if (process.env.TX_TOKEN) { - var transifex = new Transifex({ - project_slug: 'scratch-website', - credential: 'api:'+process.env.TX_TOKEN - }); -} else { - process.stdout.write('WARNING: Missing Transifex API key, skipping download.\n'); - process.stdout.write('Set TX_TOKEN in env if you want translations.\n'); - process.exit(0); -} - -//make sure general translation directory exists -var transDir = path.resolve(outputDir + '/general'); -try { - fs.accessSync(transDir, fs.F_OK); -} catch (err) { - // Doesn't exist - create it. - fs.mkdirSync(transDir); -} - -var localizations = []; -for ( var isoCode in languages ) { - var transFile = transDir + '/' + isoCode + '.json'; - localizations.push({view: 'general', lang: isoCode, file: transFile, src: 'l10n.json'}); -} - -// initialize views, ignore redirect routes -for (var v in routes) { - if (typeof routes[v].redirect !== 'undefined') { - continue; - } - var subdir = routes[v].view.split('/'); - subdir.pop(); - var l10n = 'src/views/' + subdir.join('/') + '/l10n.json'; - var name = routes[v].name; - try { - // only Initialize if there is an l10n file - fs.accessSync(l10n); - transDir = path.resolve(outputDir + '/' + name); - try { - fs.accessSync(transDir, fs.F_OK); - } catch (err) { - // Doesn't exist - create it. - fs.mkdirSync(transDir); - } - for ( var isoCode in languages ) { - var transFile = transDir + '/' + isoCode + '.json'; - localizations.push({view: name, lang: isoCode, file: transFile, src: l10n}); - } - - } catch (err) { - // skip views without l10n files - // TODO: ES6 - // process.stdout.write(`Skipping ${name}, no l10n\n`); - process.stdout.write('Skipping ' + name+ ', no l10n\n'); - } -} - -async.forEachLimit(localizations, 3, function (item, cb) { - transifex.translationInstanceMethod( - 'scratch-website', - item.view+'-l10njson', - item.lang, - {mode: 'reviewed'}, - function (err, data) { - if (err) { - process.stdout.write(item.view + ': ' + item.lang + '(' + err + ')' + ' using english\n'); - fs.createReadStream(item.src).pipe(fs.createWriteStream(item.file)); - } else { - fs.writeFile(item.file, data); - } - return; - }); - cb(); -}, function (err) { - if (err) { - process.stdout.write('Import completed with errors\n'); - } - return; -}); diff --git a/languages.json b/languages.json index ec90adaf7..d856a7885 100644 --- a/languages.json +++ b/languages.json @@ -11,6 +11,7 @@ "cy": "Cymraeg", "da": "Dansk", "de": "Deutsch", + "yum": "Edible Scratch", "et": "Eesti", "el": "Ελληνικά", "en": "English", @@ -42,6 +43,7 @@ "hu": "Magyar", "ml": "മലയാളം", "mt": "Malti", + "cat": "Meow", "mr": "मराठी", "mn": "Монгол хэл", "my": "မြန်မာဘာသာ", diff --git a/package.json b/package.json index 919dc2d6b..7135d5ae9 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,6 @@ "source-map-support": "0.3.2", "style-loader": "0.12.3", "tap": "7.1.2", - "transifex": "1.4.6", "url-loader": "0.5.6", "watch": "0.16.0", "webpack": "1.12.14",