diff --git a/src/main/webapp/public/competition.js b/src/main/webapp/public/competition.js
index c8e7352..e6cdd59 100644
--- a/src/main/webapp/public/competition.js
+++ b/src/main/webapp/public/competition.js
@@ -1,12 +1,14 @@
+import i18next from 'https://cdn.jsdelivr.net/npm/i18next@25.7.4/+esm';
+import i18nextHttpBackend from 'https://cdn.jsdelivr.net/npm/i18next-http-backend@3.0.2/+esm'
+import i18nextBrowserLanguagedetector from 'https://cdn.jsdelivr.net/npm/i18next-browser-languagedetector@8.2.0/+esm'
+
let apiUrlRoot = "";
const rootDiv = document.getElementById("safca_api_data");
-
-const header = `
Résultat de la compétition :
`
-const backButton = `Retour`
const cupImg = `
`
+
const voidFunction = () => {
}
let lastRf = 0;
@@ -41,18 +43,23 @@ function setSubPage(name) {
}
function homePage() {
- rootDiv.innerHTML = header;
+ rootDiv.innerHTML = `${i18next.t('résultatDeLaCompétition')} :
`;
let content = document.createElement('div');
content.innerHTML = `
`
rootDiv.append(content)
+
+ document.getElementById('pouleLink').addEventListener('click', () => setSubPage('poule'));
+ document.getElementById('combLink').addEventListener('click', () => setSubPage('comb'));
+ document.getElementById('clubLink').addEventListener('click', () => setSubPage('club'));
+ document.getElementById('allLink').addEventListener('click', () => setSubPage('all'));
}
let loadingAnimationStep = 0;
@@ -63,7 +70,7 @@ function startLoading(root) {
element.id = id;
const anim = setInterval(() => {
- let str = "Chargement";
+ let str = i18next.t('chargement');
for (let i = 0; i < loadingAnimationStep; i++) {
str += ".";
}
@@ -84,11 +91,11 @@ function scoreToString(score) {
const scorePrint = (s1) => {
switch (s1) {
case -997:
- return "disc.";
+ return i18next.t('disc.');
case -998:
- return "abs.";
+ return i18next.t('abs.');
case -999:
- return "for.";
+ return i18next.t('for.');
case -1000:
return "";
default:
@@ -111,11 +118,11 @@ function dateToString(date) {
let d = Math.floor((current - date_2) / (1000 * 60 * 60 * 24));
if (d === 0)
- return "Aujourd'hui à " + date_.toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"});
+ return i18next.t('aujourdhuià', {time: date_.toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"})});
else if (d === 1)
- return "Hier à " + date_.toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"});
+ return i18next.t('hierà', {time: date_.toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"})});
else if (d === 2)
- return "Avant-hier à " + date_.toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"});
+ return i18next.t('avanthierà', {time: date_.toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"})});
else
return date_.toLocaleDateString();
}
@@ -175,11 +182,11 @@ function buildPouleMenu(isPoule, change_view) {
return li;
}
- const li1 = createTab('Poule', isPoule, function () {
+ const li1 = createTab(i18next.t('poule'), isPoule, function () {
change_view(true);
});
ul.appendChild(li1);
- const li2 = createTab('Tournois', !isPoule, function () {
+ const li2 = createTab(i18next.t('tournois'), !isPoule, function () {
change_view(false);
});
ul.appendChild(li2);
@@ -195,12 +202,12 @@ function buildMatchArray(matchs) {
- | Rouge |
+ ${i18next.t('rouge')} |
|
- Scores |
+ ${i18next.t('scores')} |
|
- Bleu |
- Date |
+ ${i18next.t('bleu')} |
+ ${i18next.t('date')} |
`
for (const match of matchs) {
@@ -225,12 +232,12 @@ function buildRankArray(rankArray) {
- | Place |
- Nom |
- Victoire |
- Ratio |
- Points marqués |
- Points reçus |
+ ${i18next.t('place')} |
+ ${i18next.t('nom')} |
+ ${i18next.t('victoire')} |
+ ${i18next.t('ratio')} |
+ ${i18next.t('pointsMarqués')} |
+ ${i18next.t('pointsReçus')} |
`
for (const row of rankArray) {
@@ -255,10 +262,12 @@ function buildTree(treeData) {
}
function poulePage(location) {
- rootDiv.innerHTML = header + backButton;
+ rootDiv.innerHTML = `${i18next.t('résultatDeLaCompétition')} :
${i18next.t('back')}`;
+ document.getElementById('homeLink').addEventListener('click', () => setSubPage('home'));
+
const content = document.createElement('div');
content.style.marginTop = '1em';
- content.innerHTML = 'Recherche par catégorie
';
+ content.innerHTML = `${i18next.t('rechercheParCatégorie')}
`;
const dataContainer = document.createElement('div');
dataContainer.id = 'data-container';
@@ -286,7 +295,7 @@ function poulePage(location) {
for (const g in poule.matchs) {
if (Object.keys(poule.matchs).length > 1) {
const text = document.createElement('h4');
- text.textContent = `Groupe ${g}`;
+ text.textContent = `${i18next.t('poule')} ${g}`;
text.style.marginTop = '2em';
dataContainer.append(text);
}
@@ -303,7 +312,7 @@ function poulePage(location) {
for (const g in poule.matchs) {
if (Object.keys(poule.matchs).length > 1) {
const text = document.createElement('h4');
- text.textContent = `Groupe ${g}`;
+ text.textContent = `${i18next.t('poule')} ${g}`;
text.style.marginTop = '2em';
dataContainer.append(text);
}
@@ -323,7 +332,7 @@ function poulePage(location) {
})
.catch(e => {
console.error(e);
- dataContainer.replaceChildren(new Text("Erreur de chargement de la poule"));
+ dataContainer.replaceChildren(new Text(i18next.t('erreurDeChargementDeLaPoule')));
})
.finally(() => stopLoading(loading));
}
@@ -334,7 +343,7 @@ function poulePage(location) {
.then(poule => {
const select = document.createElement('select');
select.setAttribute('id', poule.id);
- select.innerHTML = ``;
+ select.innerHTML = ``;
for (const pouleKey of Object.keys(poule).sort((a, b) => a.toLocaleLowerCase().localeCompare(b.toLocaleLowerCase()))) {
select.innerHTML += ``;
}
@@ -356,7 +365,7 @@ function poulePage(location) {
loadPoule();
}
})
- .catch(() => rootDiv.append(new Text("Erreur de chargement des catégories")))
+ .catch(() => rootDiv.append(new Text(i18next.t('erreurDeChargementDesCatégories'))))
.finally(() => stopLoading(loading));
rfFonction = () => {
@@ -372,28 +381,33 @@ function buildCombView(comb) {
let arrayContent = `
Info :
- - Nom Prénom : ${comb.name}
- - Club : ${comb.club}
- - Catégorie : ${comb.cat}
+ - ${i18next.t('nomPrénom')} : ${comb.name}
+ - ${i18next.t('club')} : ${comb.club}
+ - ${i18next.t('catégorie')} : ${comb.cat}
- Statistique :
+ ${i18next.t('statistique')} :
- - Taux de victoire : ${comb.matchs.length === 0 ? "---" : (comb.totalWin / comb.matchs.length * 100).toFixed(0)}% (${comb.totalWin} sur ${comb.matchs.length})
- - Points marqués : ${comb.pointMake}
- - Points reçus : ${comb.pointTake}
- - Ratio du score (point marqué / point reçu): ${comb.pointRatio.toFixed(3)}
+ - ${i18next.t('tauxDeVictoire2', {
+ nb: comb.matchs.length === 0 ? "---" : (comb.totalWin / comb.matchs.length * 100).toFixed(0),
+ victoires: comb.totalWin,
+ matchs: comb.matchs.length
+ })}
+
+ - ${i18next.t('pointsMarqués2', {nb: comb.pointMake})}
+ - ${i18next.t('pointsReçus2', {nb: comb.pointTake})}
+ - ${i18next.t('ratioDuScore2', {nb: comb.pointRatio.toFixed(3)})}
- Liste des matchs:
+ ${i18next.t('listeDesMatchs')}:
- | Date |
- Poule |
- Adversaire |
- Scores |
- Ratio |
+ ${i18next.t('date')} |
+ ${i18next.t('poule')} |
+ ${i18next.t('adversaire')} |
+ ${i18next.t('scores')} |
+ ${i18next.t('ratio')} |
|
`
@@ -414,10 +428,12 @@ function buildCombView(comb) {
}
function combPage(location) {
- rootDiv.innerHTML = header + backButton;
+ rootDiv.innerHTML = `${i18next.t('résultatDeLaCompétition')} :
${i18next.t('back')}`;
+ document.getElementById('homeLink').addEventListener('click', () => setSubPage('home'));
+
const content = document.createElement('div');
content.style.marginTop = '1em';
- content.innerHTML = 'Recherche par combattant
';
+ content.innerHTML = `${i18next.t('rechercheParCombattant')}
`;
const dataContainer = document.createElement('div');
dataContainer.id = 'data-container';
@@ -430,7 +446,7 @@ function combPage(location) {
console.log(comb);
dataContainer.replaceChildren(buildCombView(comb));
})
- .catch(() => dataContainer.replaceChildren(new Text("Erreur de chargement du combattant")))
+ .catch(() => dataContainer.replaceChildren(new Text(i18next.t('erreurDeChargementDuCombattant'))))
.finally(() => stopLoading(loading));
}
@@ -439,7 +455,7 @@ function combPage(location) {
.then(response => response.json())
.then(combs => {
const select = document.createElement('select');
- select.innerHTML = ``;
+ select.innerHTML = ``;
for (const comb of Object.keys(combs).sort()) {
select.innerHTML += ``;
}
@@ -458,7 +474,7 @@ function combPage(location) {
loadComb(tmp);
}
})
- .catch(() => rootDiv.append(new Text("Erreur de chargement des combattants")))
+ .catch(() => rootDiv.append(new Text(i18next.t('erreurDeChargementDesCombattants'))))
.finally(() => stopLoading(loading));
rootDiv.append(content)
@@ -467,34 +483,34 @@ function combPage(location) {
function buildClubView(club) {
const pouleDiv = document.createElement('div');
let arrayContent = `
- Info :
+ ${i18next.t('info')} :
- - Nom : ${club.name}
- - Nombre d'inscris : ${club.nb_insc}
+ - ${i18next.t('nom')} : ${club.name}
+ - ${i18next.t('nombreDinscris')} : ${club.nb_insc}
- Statistique :
+ ${i18next.t('statistique')} :
- - Nombre de match disputé : ${club.nb_match}
- - Nombre de victoires : ${club.match_w}
- - Ratio de victoires moyen : ${club.ratioVictoire.toFixed(3)}
- - Points marqués : ${club.pointMake}
- - Points reçus : ${club.pointTake}
- - Ratio de points moyen : ${club.ratioPoint.toFixed(3)}
+ - ${i18next.t('nombreDeMatchDisputé2', {nb: club.nb_match})}
+ - ${i18next.t('nombreDeVictoires2', {nb: club.match_w})}
+ - ${i18next.t('ratioDeVictoiresMoyen2', {nb: club.ratioVictoire.toFixed(3)})}
+ - ${i18next.t('pointsMarqués2', {nb: club.pointMake})}
+ - ${i18next.t('pointsReçus2', {nb: club.pointTake})}
+ - ${i18next.t('ratioDePointsMoyen2', {nb: club.ratioPoint.toFixed(3)})}
- Liste des menbres :
+ ${i18next.t('listeDesMenbres')} :
- | Catégorie |
- Nom |
- Victoires |
- Défaites |
- Ratio victoires |
- Points marqués |
- Points reçus |
- Ratio points |
+ ${i18next.t('catégorie')} |
+ ${i18next.t('nom')} |
+ ${i18next.t('victoires')} |
+ ${i18next.t('défaites')} |
+ ${i18next.t('ratioVictoires')} |
+ ${i18next.t('pointsMarqués')} |
+ ${i18next.t('pointsReçus')} |
+ ${i18next.t('ratioPoints')} |
`
for (const comb of club.combs) {
@@ -516,10 +532,12 @@ function buildClubView(club) {
}
function clubPage(location) {
- rootDiv.innerHTML = header + backButton;
+ rootDiv.innerHTML = `${i18next.t('résultatDeLaCompétition')} :
${i18next.t('back')}`;
+ document.getElementById('homeLink').addEventListener('click', () => setSubPage('home'));
+
const content = document.createElement('div');
content.style.marginTop = '1em';
- content.innerHTML = 'Recherche par club
';
+ content.innerHTML = `${i18next.t('rechercheParClub')}
`;
const dataContainer = document.createElement('div');
dataContainer.id = 'data-container';
@@ -532,7 +550,7 @@ function clubPage(location) {
console.log(club);
dataContainer.replaceChildren(buildClubView(club));
})
- .catch(() => dataContainer.replaceChildren(new Text("Erreur de chargement du club")))
+ .catch(() => dataContainer.replaceChildren(new Text(i18next.t('erreurDeChargementDuClub'))))
.finally(() => stopLoading(loading));
}
@@ -541,7 +559,7 @@ function clubPage(location) {
.then(response => response.json())
.then(clubs => {
const select = document.createElement('select');
- select.innerHTML = ``;
+ select.innerHTML = ``;
for (const club of Object.keys(clubs).sort()) {
select.innerHTML += ``;
}
@@ -562,7 +580,7 @@ function clubPage(location) {
loadComb(tmp);
}
})
- .catch(() => rootDiv.append(new Text("Erreur de chargement des clubs")))
+ .catch(() => rootDiv.append(new Text(i18next.t('erreurDeChargementDesClubs'))))
.finally(() => stopLoading(loading));
rootDiv.append(content)
@@ -571,27 +589,27 @@ function clubPage(location) {
function buildCombsView(combs) {
const pouleDiv = document.createElement('div');
let arrayContent = `
- Statistique :
+ ${i18next.t('statistique')} :
- - Nombre d'inscris : ${combs.nb_insc}
- - Nombre de match disputé : ${combs.tt_match}
- - Points marqués : ${combs.point}
+ - ${i18next.t('nombreDinscris2', {nb: combs.nb_insc})}
+ - ${i18next.t('nombreDeMatchDisputé2', {nb: combs.tt_match})}
+ - ${i18next.t('pointsMarqués2', {nb: combs.point})}
- Liste des combattants :
+ ${i18next.t('listeDesCombattants')} :
- | Catégorie |
- Club |
- Nom |
- Victoires |
- Défaites |
- Ratio victoires |
- Points marqués |
- Points reçus |
- Ratios points |
+ ${i18next.t('catégorie')} |
+ ${i18next.t('club')} |
+ ${i18next.t('nom')} |
+ ${i18next.t('victoires')} |
+ ${i18next.t('défaites')} |
+ ${i18next.t('ratioVictoires')} |
+ ${i18next.t('pointsMarqués')} |
+ ${i18next.t('pointsReçus')} |
+ ${i18next.t('ratiosPoints')} |
`
for (const comb of combs.combs) {
@@ -614,7 +632,9 @@ function buildCombsView(combs) {
}
function combsPage() {
- rootDiv.innerHTML = header + backButton;
+ rootDiv.innerHTML = `${i18next.t('résultatDeLaCompétition')} :
${i18next.t('back')}`;
+ document.getElementById('homeLink').addEventListener('click', () => setSubPage('home'));
+
const content = document.createElement('div');
content.style.marginTop = '1em';
@@ -628,26 +648,44 @@ function combsPage() {
console.log(combs);
dataContainer.replaceChildren(buildCombsView(combs));
})
- .catch(() => dataContainer.replaceChildren(new Text("Erreur de chargement de la liste")))
+ .catch(() => dataContainer.replaceChildren(new Text(i18next.t('erreurDeChargementDeLaListe'))))
.finally(() => stopLoading(loading));
content.append(dataContainer);
rootDiv.append(content)
}
-window.addEventListener("load", () => {
- let path = document.getElementById('safca_api_script').src;
- const urlParams = new URLSearchParams(new URL(path).search);
- apiUrlRoot = path.substring(0, path.lastIndexOf('/')) + "/api/public/result/" + urlParams.get("id");
+export async function initCompetitionApi(apiUrlRoot_) {
+ apiUrlRoot = apiUrlRoot_;
+
+ const options = {
+ order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag'],
+ caches: [],
+ }
+
+ await i18next
+ .use(i18nextHttpBackend)
+ .use(i18nextBrowserLanguagedetector)
+ .init({
+ fallbackLng: 'fr',
+ debug: true,
+ interpolation: {
+ escapeValue: true,
+ },
+ detection: options,
+ ns: ['result'],
+ defaultNS: 'result',
+ })
console.log("apiUrlRoot:", apiUrlRoot)
+ console.log("FFSAF Competition API initialized.")
let hash = window.location.hash.substring(1);
if (hash.length === 0)
setSubPage('home');
else
setSubPage(hash);
-});
+}
class TreeNode {
constructor(data) {
@@ -671,7 +709,7 @@ class TreeNode {
}
function initTree(data_in) {
- out = [];
+ let out = [];
for (const din of data_in) {
out.push(parseTree(din));
}
@@ -818,7 +856,7 @@ function drawGraph(root = []) {
ctx.textBaseline = 'top';
for (let i = 0; i < scores.length; i++) {
- const score = scores[i].s1+"-"+scores[i].s2;
+ const score = scores[i].s1 + "-" + scores[i].s2;
const div = (scores.length <= 2) ? 2 : (scores.length >= 4) ? 4 : 3;
const text = ctx.measureText(score);
let dx = (size * 2 - text.width) / 2;
diff --git a/src/main/webapp/public/locales/en/result.json b/src/main/webapp/public/locales/en/result.json
new file mode 100644
index 0000000..094181e
--- /dev/null
+++ b/src/main/webapp/public/locales/en/result.json
@@ -0,0 +1,67 @@
+{
+ "--sélectionnerUnClub--": "--Select a club--",
+ "--sélectionnerUnCombattant--": "--Select a fighter--",
+ "--sélectionnerUneCatégorie--": "--Select a category--",
+ "abs.": "abs.",
+ "adversaire": "Opponent",
+ "aujourdhuià": "Today at {{time}}",
+ "avanthierà": "Day before yesterday at {{time}}",
+ "back": "« back",
+ "bleu": "Blue",
+ "catégorie": "Category",
+ "chargement": "Loading",
+ "club": "Club",
+ "combattant": "Fighter",
+ "combattants": "Fighters",
+ "date": "Date",
+ "disc.": "DQ",
+ "défaites": "Losses",
+ "erreurDeChargementDeLaListe": "Error loading the list",
+ "erreurDeChargementDeLaPoule": "Error loading the pool",
+ "erreurDeChargementDesCatégories": "Error loading categories",
+ "erreurDeChargementDesClubs": "Error loading clubs",
+ "erreurDeChargementDesCombattants": "Error loading fighters",
+ "erreurDeChargementDuClub": "Error loading club",
+ "erreurDeChargementDuCombattant": "Error loading fighter",
+ "for.": "forf.",
+ "hierà": "Yesterday at {{time}}",
+ "info": "Info",
+ "listeDesCombattants": "List of fighters",
+ "listeDesMatchs": "List of matches",
+ "listeDesMembres": "List of members",
+ "listeDesMenbres": "List of members",
+ "nom": "Last name",
+ "nomPrénom": "Last name First name",
+ "nombreDeMatchDisputé2": "Number of matches played: {{nb}}",
+ "nombreDeVictoires2": "Number of wins: {{nb}}",
+ "nombreDinscris": "Number of registered",
+ "nombreDinscris2": "Number of registered: {{nb}}",
+ "parCatégorie": "By category",
+ "parClub": "By club",
+ "parCombattant": "By fighter",
+ "place": "Place",
+ "pointsMarqués": "Points scored",
+ "pointsMarqués2": "Points scored: {{nb}}",
+ "pointsReçus": "Points received",
+ "pointsReçus2": "Points received: {{nb}}",
+ "poule": "Pool",
+ "ratio": "Ratio",
+ "ratioDePointsMoyen2": "Average points ratio: {{nb}}",
+ "ratioDeVictoiresMoyen2": "Average win ratio: {{nb}}",
+ "ratioDuScore2": "Score ratio (points scored / points received): {{nb}}",
+ "ratioPoints": "Points ratio",
+ "ratioVictoires": "Win ratio",
+ "ratiosPoints": "Points ratios",
+ "rechercheParCatégorie": "Search by category",
+ "rechercheParClub": "Search by club",
+ "rechercheParCombattant": "Search by fighter",
+ "rouge": "Red",
+ "résultatDeLaCompétition": "Competition result",
+ "scores": "Scores",
+ "statistique": "Statistics",
+ "tauxDeVictoire2": "Win rate: {{nb}}% ({{victoires}} out of {{matchs}})",
+ "tournois": "Tournaments",
+ "tousLesCombattants": "All fighters",
+ "victoire": "Win",
+ "victoires": "Wins"
+}
diff --git a/src/main/webapp/public/locales/fr/result.json b/src/main/webapp/public/locales/fr/result.json
new file mode 100644
index 0000000..2122fd0
--- /dev/null
+++ b/src/main/webapp/public/locales/fr/result.json
@@ -0,0 +1,67 @@
+{
+ "--sélectionnerUnClub--": "--Sélectionner un club--",
+ "--sélectionnerUnCombattant--": "--Sélectionner un combattant--",
+ "--sélectionnerUneCatégorie--": "--Sélectionner une catégorie--",
+ "abs.": "abs.",
+ "adversaire": "Adversaire",
+ "aujourdhuià": "Aujourd'hui à {{time}}",
+ "avanthierà": "Avant-hier à {{time}}",
+ "back": "« retour",
+ "bleu": "Bleu",
+ "catégorie": "Catégorie",
+ "chargement": "Chargement",
+ "club": "Club",
+ "combattant": "Combattant",
+ "combattants": "Combattants",
+ "date": "Date",
+ "disc.": "disc.",
+ "défaites": "Défaites",
+ "erreurDeChargementDeLaListe": "Erreur de chargement de la liste",
+ "erreurDeChargementDeLaPoule": "Erreur de chargement de la poule",
+ "erreurDeChargementDesCatégories": "Erreur de chargement des catégories",
+ "erreurDeChargementDesClubs": "Erreur de chargement des clubs",
+ "erreurDeChargementDesCombattants": "Erreur de chargement des combattants",
+ "erreurDeChargementDuClub": "Erreur de chargement du club",
+ "erreurDeChargementDuCombattant": "Erreur de chargement du combattant",
+ "for.": "for.",
+ "hierà": "Hier à {{time}}",
+ "info": "Info",
+ "listeDesCombattants": "Liste des combattants",
+ "listeDesMatchs": "Liste des matchs",
+ "listeDesMembres": "Liste des membres",
+ "listeDesMenbres": "Liste des menbres",
+ "nom": "Nom",
+ "nomPrénom": "Nom Prénom",
+ "nombreDeMatchDisputé2": "Nombre de match disputé : {{nb}}",
+ "nombreDeVictoires2": "Nombre de victoires : {{nb}} ",
+ "nombreDinscris": "Nombre d'inscris",
+ "nombreDinscris2": "Nombre d'inscris : {{nb}}",
+ "parCatégorie": "Par catégorie",
+ "parClub": "Par club",
+ "parCombattant": "Par combattant",
+ "place": "Place",
+ "pointsMarqués": "Points marqués",
+ "pointsMarqués2": "Points marqués : {{nb}}",
+ "pointsReçus": "Points reçus",
+ "pointsReçus2": "Points reçus : {{nb}}",
+ "poule": "Poule",
+ "ratio": "Ratio",
+ "ratioDePointsMoyen2": "Ratio de points moyen : {{nb}}",
+ "ratioDeVictoiresMoyen2": "Ratio de victoires moyen : {{nb}}",
+ "ratioDuScore2": "Ratio du score (point marqué / point reçu): {{nb}}",
+ "ratioPoints": "Ratio points",
+ "ratioVictoires": "Ratio victoires",
+ "ratiosPoints": "Ratios points",
+ "rechercheParCatégorie": "Recherche par catégorie",
+ "rechercheParClub": "Recherche par club",
+ "rechercheParCombattant": "Recherche par combattant",
+ "rouge": "Rouge",
+ "résultatDeLaCompétition": "Résultat de la compétition",
+ "scores": "Scores",
+ "statistique": "Statistique",
+ "tauxDeVictoire2": "Taux de victoire : {{nb}}% ({{victoires}} sur {{matchs}})",
+ "tournois": "Tournois",
+ "tousLesCombattants": "Tous les combattants",
+ "victoire": "Victoire",
+ "victoires": "Victoires"
+}
diff --git a/src/main/webapp/src/config/i18n.js b/src/main/webapp/src/config/i18n.js
index b9bbe24..41dc448 100644
--- a/src/main/webapp/src/config/i18n.js
+++ b/src/main/webapp/src/config/i18n.js
@@ -26,7 +26,7 @@ i18n
escapeValue: false, // not needed for react as it escapes by default
},
detection: options,
- ns: ['common'],
+ ns: ['common', 'result'],
defaultNS: 'common',
});
diff --git a/src/main/webapp/src/pages/competition/editor/CMAdmin.jsx b/src/main/webapp/src/pages/competition/editor/CMAdmin.jsx
index 1fd1290..bbbaf72 100644
--- a/src/main/webapp/src/pages/competition/editor/CMAdmin.jsx
+++ b/src/main/webapp/src/pages/competition/editor/CMAdmin.jsx
@@ -217,8 +217,12 @@ function Menu({menuActions, compUuid}) {
}
const copyScriptToClipboard = () => {
- navigator.clipboard.writeText(`
- `
+ navigator.clipboard.writeText(`
+
+`
).then(() => {
toast.success("Texte copié dans le presse-papier ! Collez-le dans une balise HTML sur votre WordPress.");
}).catch(err => {
diff --git a/src/main/webapp/src/pages/result/ResultList.jsx b/src/main/webapp/src/pages/result/ResultList.jsx
index 6baccb6..ef26cfe 100644
--- a/src/main/webapp/src/pages/result/ResultList.jsx
+++ b/src/main/webapp/src/pages/result/ResultList.jsx
@@ -3,7 +3,7 @@ import {useLoadingSwitcher} from "../../hooks/useLoading.jsx";
import {useFetch} from "../../hooks/useFetch.js";
import {AxiosError} from "../../components/AxiosError.jsx";
import {ThreeDots} from "react-loader-spinner";
-import {useAuth} from "../../hooks/useAuth.jsx";
+import {useTranslation} from "react-i18next";
export function ResultList() {
const navigate = useNavigate();
@@ -25,14 +25,15 @@ export function ResultList() {
}
function MakeCentralPanel({data, navigate}) {
+ const {t} = useTranslation();
return <>
-
Compétition:
+
{t('competition', {count: data.length})}:
{data.sort((a, b) => new Date(b[2].split('T')[0]) - new Date(a[2].split('T')[0])).map((o) => (
navigate(`${o[0]}`)}>{o[1]}))}
+ onClick={() => navigate(`${o[0]}`)}>{o[1]}))}
>
diff --git a/src/main/webapp/src/pages/result/ResultRoot.jsx b/src/main/webapp/src/pages/result/ResultRoot.jsx
index e95ff48..0bba34b 100644
--- a/src/main/webapp/src/pages/result/ResultRoot.jsx
+++ b/src/main/webapp/src/pages/result/ResultRoot.jsx
@@ -2,10 +2,13 @@ import {LoadingProvider} from "../../hooks/useLoading.jsx";
import {Outlet} from "react-router-dom";
import {ResultList} from "./ResultList.jsx";
import {ResultView} from "./ResultView.jsx";
+import {useTranslation} from "react-i18next";
export function ResultRoot() {
+ const {t} = useTranslation();
+
return <>
- Résultat
+ {t("result", {count: 1})}
diff --git a/src/main/webapp/src/pages/result/ResultView.jsx b/src/main/webapp/src/pages/result/ResultView.jsx
index c17c07e..a314c2f 100644
--- a/src/main/webapp/src/pages/result/ResultView.jsx
+++ b/src/main/webapp/src/pages/result/ResultView.jsx
@@ -7,6 +7,7 @@ import React, {useEffect, useState} from "react";
import {DrawGraph} from "./DrawGraph.jsx";
import {TreeNode} from "../../utils/TreeUtils.js";
import {scoreToString} from "../../utils/CompetitionTools.js";
+import {useTranslation} from "react-i18next";
function CupImg() {
return
@@ -40,22 +42,23 @@ export function ResultView() {
// || resultShow && resultShow === "club_all" &&
function MenuBar({resultShow, setResultShow}) {
+ const {t} = useTranslation('result');
return
@@ -69,15 +72,16 @@ function MenuBar({resultShow, setResultShow}) {
}
function BuildMatchArray({matchs}) {
+ const {t} = useTranslation('result');
return <>
- | Rouge |
+ {t('rouge')} |
|
- Scores |
+ {t('scores')} |
|
- Bleu |
+ {t('bleu')} |
@@ -94,16 +98,17 @@ function BuildMatchArray({matchs}) {
}
function BuildRankArray({rankArray}) {
+ const {t} = useTranslation('result');
return <>
- | Place |
- Nom |
- Victoire |
- Ratio |
- Points marqués |
- Points reçus |
+ {t('place')} |
+ {t('nom')} |
+ {t('victoire')} |
+ {t('ratio')} |
+ {t('pointsMarqués')} |
+ {t('pointsReçus')} |
@@ -147,6 +152,7 @@ function CategoryList({uuid}) {
const [catId, setCatId] = useState(null)
const setLoading = useLoadingSwitcher()
const {data, error} = useFetch(`/result/${uuid}/category/list`, setLoading, 1)
+ const {t} = useTranslation('result');
useEffect(() => {
if (data && Object.keys(data).length > 0)
@@ -155,7 +161,7 @@ function CategoryList({uuid}) {
return <>
{data ?
-
Catégorie
+
{t('catégorie')}