mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-05-17 08:10:59 -04:00
Fix #940
Most problems were due to strings being duplicated and overwriting each other. Updated the build-locales script to keep track of duplicates. Project Curated by on the splash page was just missing the formatMessage call.
This commit is contained in:
parent
9f93340539
commit
1339683a73
4 changed files with 32 additions and 12 deletions
|
@ -97,7 +97,8 @@ for (var v in routes) {
|
|||
en: ids
|
||||
};
|
||||
idsWithICU = merge(idsWithICU, localeCompare.idToICUMap(routes[v].name, ids));
|
||||
icuWithIds = merge(icuWithIds, localeCompare.icuToIdMap(routes[v].name, ids));
|
||||
// Note: if lodash.merge gets updated to 4.0 or higher this needs to be mergeWith instead
|
||||
icuWithIds = merge(icuWithIds, localeCompare.icuToIdMap(routes[v].name, ids), localeCompare.customMerge);
|
||||
} catch (err) {
|
||||
if (err.code !== 'MODULE_NOT_FOUND') {
|
||||
throw err;
|
||||
|
|
|
@ -6,6 +6,7 @@ var crypto = require('crypto');
|
|||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var po2icu = require('po2icu');
|
||||
var isArray = require('lodash.isArray');
|
||||
|
||||
var Helpers = {};
|
||||
|
||||
|
@ -20,6 +21,21 @@ Helpers.getMD5 = function (string) {
|
|||
return crypto.createHash('md5').update(cleanedString, 'utf8').digest('hex');
|
||||
};
|
||||
|
||||
/**
|
||||
* Customizer for icuWithIds merge.
|
||||
* If icu key already has an id value, concatenate additional ids instead
|
||||
* of replacing.
|
||||
*
|
||||
* @param {array} objVal current value
|
||||
* @param {string} srcVal new value
|
||||
* @return {array} objVal with srcVal concatenated
|
||||
*/
|
||||
Helpers.customMerge = function (objVal, srcVal) {
|
||||
if (isArray(objVal)) {
|
||||
return objVal.concat(srcVal);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Existing translations should be in the key value format specified by react-intl (i.e.
|
||||
formatted message id, with icu string as the value). New Translations should be in the
|
||||
|
@ -33,7 +49,9 @@ Helpers.mergeNewTranslations = function (existingTranslations, newTranslations,
|
|||
for (var id in newTranslations) {
|
||||
var md5 = Helpers.getMD5(id);
|
||||
if (md5Map.hasOwnProperty(md5) && newTranslations[id].length > 0) {
|
||||
existingTranslations[md5Map[md5]] = newTranslations[id];
|
||||
md5Map[md5].forEach(function (msgId) {
|
||||
existingTranslations[msgId] = newTranslations[id];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,7 +164,7 @@ Helpers.icuToIdMap = function (viewName, ids, separator) {
|
|||
separator = separator || ':';
|
||||
|
||||
for (var id in ids) {
|
||||
icuToIds[ids[id]] = viewName + separator + id;
|
||||
icuToIds[ids[id]] = [viewName + separator + id];
|
||||
}
|
||||
return icuToIds;
|
||||
};
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
"keymirror": "0.1.1",
|
||||
"lodash.clone": "3.0.3",
|
||||
"lodash.defaultsdeep": "3.10.0",
|
||||
"lodash.isarray": "^3.0.4",
|
||||
"lodash.merge": "3.3.2",
|
||||
"lodash.omit": "3.1.0",
|
||||
"lodash.range": "3.0.1",
|
||||
|
|
|
@ -215,7 +215,7 @@ var Splash = injectIntl(React.createClass({
|
|||
<Box
|
||||
key="curator_top_projects"
|
||||
title={
|
||||
'Projects Curated by ' +
|
||||
formatMessage({id: 'splash.projectsCuratedBy', defaultMessage: 'Projects Curated by '}) +
|
||||
this.state.featuredGlobal.curator_top_projects[0].curator_name}
|
||||
moreTitle={formatMessage({id: 'general.learnMore', defaultMessage: 'Learn More'})}
|
||||
moreHref="/studios/386359/">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue