diff options
Diffstat (limited to 'src/data')
| -rw-r--r-- | src/data/things/Language.js | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/src/data/things/Language.js b/src/data/things/Language.js index 5265d851..8b8c78b7 100644 --- a/src/data/things/Language.js +++ b/src/data/things/Language.js @@ -732,31 +732,49 @@ export class Language extends Thing { : duration; } - formatExternalLink(url, { + formatExternalLink(urlEntry, { style = 'platform', context = 'generic', } = {}) { // Null or undefined url is blank content. - if (url === null || url === undefined) { + if (urlEntry === null || urlEntry === undefined) { return html.blank(); } + // String means we're probably receiving a URL, not a URL entry. + // Just fill in blanks like from a mock/dummy entry. + if (typeof urlEntry === 'string') { + return this.formatExternalLink( + { + url: urlEntry, + annotation: null, + }, + {style, context}); + } + isExternalLinkContext(context); if (style === 'all') { - return getExternalLinkStringsFromDescriptors(url, externalLinkSpec, { - language: this, - context, - }); + return getExternalLinkStringsFromDescriptors( + urlEntry, + externalLinkSpec, + { + language: this, + context, + }); } isExternalLinkStyle(style); const result = - getExternalLinkStringOfStyleFromDescriptors(url, style, externalLinkSpec, { - language: this, - context, - }); + getExternalLinkStringOfStyleFromDescriptors( + urlEntry, + style, + externalLinkSpec, + { + language: this, + context, + }); // It's possible for there to not actually be any string available for the // given URL, style, and context, and we want this to be detectable via @@ -803,11 +821,16 @@ export class Language extends Thing { } #formatListHelper(array, processFn) { + // Empty lists, null, and undefined are blank content. + if (empty(array) || array === null || array === undefined) { + return html.blank(); + } + // Blank items aren't for display. array = array.filter(item => !html.isBlank(item)); - // Empty lists, null, and undefined are blank content. - if (empty(array) || array === null || array === undefined) { + // Empty lists are blank content. (2, The Sequel) + if (empty(array)) { return html.blank(); } @@ -955,7 +978,6 @@ export class Language extends Thing { const countHelper = (stringKey, optionName = stringKey) => function(value, { unit = false, - unitOnly = false, blankIfZero = false, } = {}) { // Null or undefined value is blank content. @@ -969,16 +991,11 @@ const countHelper = (stringKey, optionName = stringKey) => } const string = - (unitOnly - ? `count.${stringKey}.unitOnly.` + this.getUnitForm(value) - : unit + (unit ? `count.${stringKey}.withUnit.` + this.getUnitForm(value) : `count.${stringKey}`); - const options = - (unitOnly - ? {} - : {[optionName]: this.formatNumber(value)}); + const options = {[optionName]: this.formatNumber(value)}; return this.formatString(string, options); }; |