Merge pull request #2865 from chrisgarrity/issue/2665-l10n

Remove dependency on scratchr2_translations
This commit is contained in:
chrisgarrity 2019-04-01 11:33:49 +02:00 committed by GitHub
commit 5fbfc55deb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 23 deletions

View file

@ -80,6 +80,12 @@ source_file = src/views/splash/l10n.json
source_lang = en
type = KEYVALUEJSON
[scratch-website.conference-index-2019-l10njson]
file_filter = localizations/conference-index-2019/<lang>.json
source_file = src/views/conference/2019/index/l10n.json
source_lang = en
type = KEYVALUEJSON
[scratch-website.conference-index-2017-l10njson]
file_filter = localizations/conference-index-2017/<lang>.json
source_file = src/views/conference/2017/index/l10n.json
@ -92,12 +98,6 @@ source_file = src/views/credits/l10n.json
source_lang = en
type = KEYVALUEJSON
[scratch-website.tips-l10njson]
file_filter = localizations/tips/<lang>.json
source_file = src/views/tips/l10n.json
source_lang = en
type = KEYVALUEJSON
[scratch-website.download-l10njson]
file_filter = localizations/download/<lang>.json
source_file = src/views/download/l10n.json
@ -122,12 +122,6 @@ source_file = src/views/messages/l10n.json
source_lang = en
type = KEYVALUEJSON
[scratch-website.preview-faq-l10njson]
file_filter = localizations/preview-faq/<lang>.json
source_file = src/views/preview-faq/l10n.json
source_lang = en
type = KEYVALUEJSON
[scratch-website.research-l10njson]
file_filter = localizations/research/<lang>.json
source_file = src/views/research/l10n.json
@ -150,12 +144,6 @@ source_file = src/views/microbit/l10n.json
source_lang = en
type = KEYVALUEJSON
[scratch-website.3faq-l10njson]
file_filter = localizations/preview-faq/<lang>.json
source_file = src/views/preview-faq/l10n.json
source_lang = en
type = KEYVALUEJSON
[scratch-website.search-l10njson]
file_filter = localizations/search/<lang>.json
source_file = src/views/search/l10n.json
@ -181,3 +169,8 @@ type = KEYVALUEJSON
source_file = src/views/ideas/l10n.json
source_lang = en
type = KEYVALUEJSON
[scratch-website.starter-projects-l10njson]
source_file = src/views/starter-projects/l10n.json
source_lang = en
type = KEYVALUEJSON

View file

@ -38,7 +38,7 @@ deploy:
translations:
./bin/get-localized-urls localized-urls.json
./bin/build-locales node_modules/scratchr2_translations/www/translations intl
./bin/build-locales node_modules/scratch-l10n/www intl
webpack:
$(WEBPACK) --bail

View file

@ -123,6 +123,16 @@ var defaultLocales = {
var views = [];
var localizedAssetUrls = {};
// Most views will have the same name for:
// - the view folder
// - the route name
// - the transifex resource
// Add exceptions:
// - txMapping: if the name of the transifex resource is different from the route name
var txMapping = {
'projects': 'preview',
'scratch_1.4': 'scratch_14' // transifex doesn't allow dots in resource names
};
// start with english default for all views
for (var v in routes) {
if (typeof routes[v].redirect !== 'undefined') {
@ -193,11 +203,12 @@ async.forEachLimit(views, 5, function (view, cb) {
// merge view specific english strings, first then other languages
async.forEach(allLangs, function (isoCode, cb) {
var txResource = txMapping[view] || view;
var translationsFile = path.resolve(
__dirname,
'../',
localesDir,
'scratch-website.' + view + '-l10njson',
'scratch-website.' + txResource + '-l10njson',
isoCode + '.json'
);
fs.readFile(translationsFile, 'utf8', function (err, data) {

View file

@ -11,7 +11,10 @@
"smoke-sauce": "SMOKE_REMOTE=true tap ./test/integration/smoke-testing/*.js --timeout=60000",
"watch": "make watch",
"build": "make build",
"dev": "make watch && make start &"
"dev": "make watch && make start &",
"translate:urls": "node ./bin/get-localized-urls localized-urls.json",
"translate:files": "node ./bin/build-locales node_modules/scratch-l10n/www intl",
"translate": "npm run translate:urls && npm run translate:files"
},
"repository": {
"type": "git",
@ -104,7 +107,6 @@
"redux-thunk": "2.0.1",
"sass-loader": "6.0.6",
"scratch-l10n": "latest",
"scratchr2_translations": "git://github.com/LLK/scratchr2_translations.git#master",
"slick-carousel": "1.6.0",
"source-map-support": "0.3.2",
"style-loader": "0.12.3",

View file

@ -2,7 +2,7 @@ var fs = require('fs');
var glob = require('glob');
var tap = require('tap');
var TRANSLATIONS_PATTERN = './node_modules/scratchr2_translations/www/**/*.json';
var TRANSLATIONS_PATTERN = './node_modules/scratch-l10n/www/**/*.json';
var files = glob.sync(TRANSLATIONS_PATTERN);
const checkJson = (data, name) => {