Skip to content

Commit

Permalink
complete translations
Browse files Browse the repository at this point in the history
  • Loading branch information
robindemourat committed Aug 13, 2024
1 parent bfc0a39 commit 0fa6d8f
Show file tree
Hide file tree
Showing 11 changed files with 847 additions and 470 deletions.
4 changes: 2 additions & 2 deletions datascripts/fetch_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ def set_humain_quote_id(item_metas):
for i, item in enumerate(summary):
if i == 0:
continue
print("item:")
print(item)
# print("item:")
# print(item)
base_str = json.dumps(item, indent = 2, ensure_ascii=False)[:-2]
base_str += ",\n";
component = "ScrollyPage" if '"navGroup": "primary"' in base_str and 'conclusion' not in base_str.lower() else "PlainPage"
Expand Down
230 changes: 196 additions & 34 deletions src/i18n/messages.yml

Large diffs are not rendered by default.

38 changes: 35 additions & 3 deletions src/utils/colorPalettes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const colorsPalettes = {
Provence: "#668EDB",
Lyonnais: "#41BEA3",
Languedoc: "#A7E6F9",

Corse: "#514EEE",
'Isles de Corse': "#514EEE",
},
Expand Down Expand Up @@ -174,21 +174,53 @@ const colorsPalettes = {
provenanceCountries: {
France: '#EE7993',
'Empire ottoman': '#019d2f',

'Péninsule italienne': '#E27A0B',
Espagne: '#E25C0B',
'Provinces-Unies': '#c8c8f0',
'Grande-Bretagne et colonies (Terre-Neuve)': '#c9072a',
autre: '#c4c4c4',
fr: {
France: '#EE7993',
'Empire ottoman': '#019d2f',
'Péninsule italienne': '#E27A0B',
Espagne: '#E25C0B',
'Provinces-Unies': '#c8c8f0',
'Grande-Bretagne et colonies (Terre-Neuve)': '#c9072a',
Autres: '#c4c4c4',
},
en: {
France: '#EE7993',
'Ottoman empire': '#019d2f',
'Italian peninsula': '#E27A0B',
Spain: '#E25C0B',
'United provinces': '#c8c8f0',
'Great Britain and colonies (Newfoundland)': '#c9072a',
Others: '#c4c4c4',
}
},
partnersGrouped: {
'Levant & Barbarie': '#019d2f',
'Italie & Espagne': '#DFBD3A',
'Angleterre & Amérique du Nord': '#c9072a',
'Colonies françaises': '#E5881A',
// 'Colonies': '#E5881A',
'Nord, Hollande & Flandres': '#c8c8f0',
'total': '#c4c4c4',
en: {
'Levant & Barbary': '#019d2f',
'Italy & Spain': '#DFBD3A',
'England & North America': '#c9072a',
'French colonies': '#E5881A',
'North, Holland & Flanders': '#c8c8f0',
'total': '#c4c4c4',
},
fr: {
'Levant & Barbarie': '#019d2f',
'Italie & Espagne': '#DFBD3A',
'Angleterre & Amérique du Nord': '#c9072a',
'Colonies françaises': '#E5881A',
'Nord, Hollande & Flandres': '#c8c8f0',
'total': '#c4c4c4',
}
},
Marseille: 'red',
warStatus: {
Expand Down
148 changes: 65 additions & 83 deletions src/visualizations/EffetsGuerreSurLevant/EffetsGuerreSurLevant.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,55 @@ import { formatNumber } from "../../utils/misc";
import BarChart from "../../components/BarChart";

import colorsPalettes from "../../utils/colorPalettes";
import { useMemo } from "react";

const {partnersGrouped: palette} = colorsPalettes;
const { partnersGrouped: palette } = colorsPalettes;

const orderMap = Object.keys(palette).reduce((res, key, i) => ({
...res,
[key]: i,
}), {})

export default function EffetsGuerreSurLevant({
data: inputData,
width,
height,
lang
}) {
const orderMap = Object.keys(palette[lang]).reduce((res, key, i) => ({
...res,
[key]: i,
}), {})
// const data = useMemo(() =>
const data = (inputData.get('evolution-exports-levant.csv') || [])
.map(d => ({
...d,
year: +d.year,
value: +d.value,
order: orderMap[d.group],
orderReversed: -orderMap[d.group]
}))
const data = useMemo(() => (inputData.get('evolution-exports-levant.csv') || [])
.map(d => {
let translatedGroup;
switch (d.group) {
case 'Levant & Barbarie':
translatedGroup = translate('EffetsGuerreSurLevant', 'group-levant-barbarie', lang)
break;
case 'Italie & Espagne':
translatedGroup = translate('EffetsGuerreSurLevant', 'group-italie-espagne', lang)
break;
case 'Angleterre & Amérique du Nord':
translatedGroup = translate('EffetsGuerreSurLevant', 'group-angleterre', lang)
break;
case 'Colonies françaises':
translatedGroup = translate('EffetsGuerreSurLevant', 'group-colonies', lang)
break;
case 'Nord, Hollande & Flandres':
translatedGroup = translate('EffetsGuerreSurLevant', 'group-nord', lang)
break;
case 'total':
default:
translatedGroup = translate('EffetsGuerreSurLevant', 'group-total', lang)
break;
}
return {
...d,
group: translatedGroup,
year: +d.year,
value: +d.value,
order: orderMap[d.group],
orderReversed: -orderMap[d.group]
}
})
.sort((a, b) => {
if (a.year > b.year) {
return 1;
Expand All @@ -39,85 +65,30 @@ export default function EffetsGuerreSurLevant({
return 1;
}
return -1;
})
// .filter(d => d.group !== 'total')
// , []);
}), [inputData, translate, lang]);

const totalValuesMap = data.filter(d => d.group === 'total').reduce((res, { year, value }) => ({
...res,
[year]: value
}), {})

const messages = {
franceOverviewTitle: (start, end, kind, slope) =>
translate("viz-1-A", "franceOverviewTitle", lang, {
start: start,
end: end,
kind,
slope,
}),
tradeEvolutionTitle: (cityName, start, end, kind, slope) =>
translate("viz-1-A", "tradeEvolutionTitle", lang, {
cityName,
start,
end,
kind,
}),
// top90PctTitle: (cityName, start, end) =>
// translate("viz-1-A", "top90PctTitle", lang, {
// cityName: cityName,
// start: start,
// end: end,
// }),
partInPct: (kind) => translate("viz-1-A", "partInPct", lang, { kind }),
absoluteValue: (kind) =>
translate("viz-1-A", "absoluteValue", lang, { kind }),
regressionTitle: (slope) =>
translate("viz-1-A", "regressionTitle", lang, { slope }),
// herfindalLegendTitle: () =>
// translate("viz-1-A", "herfindalLegendTitle", lang),
// herfindal0: () => translate("viz-1-A", "herfindal0", lang),
// herfindal1: () => translate("viz-1-A", "herfindal1", lang),
barTooltip: (year, pct, city, herfindal) =>
translate("viz-1-A", "barTooltip", lang, {
year: year,
pct: pct,
city: city,
herfindal: herfindal,
}),
productTooltip: (year, product, pct) =>
translate("viz-1-A", "productTooltip", lang, {
year: year,
product: product,
pct: pct,
}),
sevenYearsWar: (year, product, pct) =>
translate("viz-1-A", "sevenYearsWar", lang, {
year: year,
product: product,
pct: pct,
}),
austriaWar: () => translate("viz-1-A", "austriaWar", lang),
usIndependance: () => translate("viz-1-A", "usIndependance", lang),
};

const annotations = [
const annotations = useMemo(() => [

{
type: "span",
start: 1744,
end: 1748,
row: 0.5,
axis: 'x',
label: messages.austriaWar(),
label: translate("viz-1-A", "austriaWar", lang),
},
{
type: "span",
start: 1756,
end: 1763,
axis: 'x',
labelPosition: height / 10,
label: messages.sevenYearsWar(),
label: translate("viz-1-A", "sevenYearsWar", lang),
},
{
type: "span",
Expand All @@ -126,35 +97,41 @@ export default function EffetsGuerreSurLevant({
labelPosition: height / 5,
row: 3,
axis: 'x',
label: messages.usIndependance(),
label: translate("viz-1-A", "usIndependance", lang),
},
];
], [translate, lang]);
return (
<div className="EffetsGuerreSurLevant">
<LineChart
{
...{
width,
height: height / 2,
title: `Principaux partenaires étrangers des importations de Marseille`,
title: translate('EffetsGuerreSurLevant', 'title', lang),
data,
annotations,
color: {
field: 'group',
palette
palette: palette[lang]
},
x: {
field: 'year',
title: 'année',
title: translate('EffetsGuerreSurLevant', 'top-x-axis', lang),
},
y: {
field: 'value',
title: 'valeur des imports',
title: translate('EffetsGuerreSurLevant', 'top-y-axis', lang),
// tickSpan: 100000000,
// domain: [0, 200000000],
tickFormat: d => formatNumber(d) + ' lt.'
},
tooltip: d => `En ${d.year}, Marseille a importé ${formatNumber(parseInt(d.value))} lt. depuis les partenaires ${d.group === 'total' ? 'au' : 'de'} ${d.group}`
tooltip: d => translate('EffetsGuerreSurLevant', 'top-tooltip', lang, {
year: d.year,
value: formatNumber(parseInt(d.value)),
particule: d.group === 'total' ? 'au' : 'de',
group: d.group
})
// `En ${d.year}, Marseille a importé ${formatNumber(parseInt(d.value))} lt. depuis les partenaires ${d.group === 'total' ? 'au' : 'de'} ${d.group}`
}
}
/>
Expand All @@ -179,25 +156,30 @@ export default function EffetsGuerreSurLevant({
// annotations,
color: {
field: 'group',
palette
palette: palette[lang]
},
hideLegend: true,
x: {
field: 'year',
title: 'année',
title: translate('EffetsGuerreSurLevant', 'bottom-x-axis', lang),
tickFormat: d => d % 5 === 0 ? d : '',
// domain: [1725, 1790]
},
y: {
field: 'value',
title: 'part des imports',
title: translate('EffetsGuerreSurLevant', 'bottom-y-axis', lang),
tickFormat: d => d + '%',
sort: {
field: 'orderReversed',
type: 'number'
}
},
tooltip: d => `En ${d.year}, Marseille a importé ${parseInt(d.value)} % de sa valeur depuis les partenaires ${d.group}`
tooltip: d => translate('EffetsGuerreSurLevant', 'bottom-tooltip', lang, {
year: d.year,
share: parseInt(d.value),
group: d.group
})
// `En ${d.year}, Marseille a importé ${parseInt(d.value)} % de sa valeur depuis les partenaires ${d.group}`
}
}
/>
Expand Down
Loading

0 comments on commit 0fa6d8f

Please sign in to comment.