Skip to content

Commit

Permalink
Merge branch 'pr-994'
Browse files Browse the repository at this point in the history
* pr-994:
  Fix linting, key names and double period ".." strings
  add periods to english translations
  Fixes nextstrain#993 by creating separate translations for compound sentences
  • Loading branch information
jameshadfield committed Mar 26, 2020
2 parents 7149275 + b03d87c commit 6eec12e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
26 changes: 18 additions & 8 deletions src/components/info/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,39 @@ const arrayToSentence = (arr, {prefix=undefined, suffix=undefined, capatalise=tr
export const createSummary = (mainTreeNumTips, nodes, filters, visibility, visibleStateCounts, branchLengthsToDisplay, t) => {
const nSelectedSamples = getNumSelectedTips(nodes, visibility);
const sampledDateRange = getVisibleDateRange(nodes, visibility);
let summary = ""; /* text returned from this function */

/* Number of genomes & their date range */
let summary = t(
"Showing {{x}} of {{y}} genomes",
{x: nSelectedSamples, y: mainTreeNumTips}
);
if (branchLengthsToDisplay !== "divOnly") {
summary += " " + t(
"sampled between {{from}} and {{to}}",
{from: styliseDateRange(sampledDateRange[0]), to: styliseDateRange(sampledDateRange[1])}
summary += t(
"Showing {{x}} of {{y}} genomes sampled between {{from}} and {{to}}.",
{
x: nSelectedSamples,
y: mainTreeNumTips,
from: styliseDateRange(sampledDateRange[0]),
to: styliseDateRange(sampledDateRange[1])
}
);
} else {
summary += t(
"Showing {{x}} of {{y}} genomes.",
{x: nSelectedSamples, y: mainTreeNumTips}
);
}

/* parse filters */
const filterTextArr = [];
Object.keys(filters).forEach((filterName) => {
const n = Object.keys(visibleStateCounts[filterName]).length;
if (!n) return;
filterTextArr.push(`${n} ${pluralise(filterName, n)}`);
});
const prefix = branchLengthsToDisplay !== "divOnly" ? t("and comprising") : t("comprising");
const prefix = t("Comprising");
const filterText = arrayToSentence(filterTextArr, {prefix: prefix, capatalise: false});
if (filterText.length) {
summary += ` ${filterText}`;
} else if (summary.endsWith('.')) {
summary += " ";
} else {
summary += ". ";
}
Expand Down
7 changes: 3 additions & 4 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@


"__Header//Info__": "########################################",
"Showing {{x}} of {{y}} genomes": "Showing {{x}} of {{y}} genomes",
"sampled between {{from}} and {{to}}": "sampled between {{from}} and {{to}}",
"and comprising": "and comprising",
"comprising": "comprising",
"Showing {{x}} of {{y}} genomes.": "Showing {{x}} of {{y}} genomes.",
"Showing {{x}} of {{y}} genomes sampled between {{from}} and {{to}}.": "Showing {{x}} of {{y}} genomes sampled between {{from}} and {{to}}.",
"Comprising": "Comprising",
"Animation in progress.": "Animation in progress.",
"Filtered to": "Filtered to",

Expand Down

0 comments on commit 6eec12e

Please sign in to comment.