diff --git a/frontend/src/auth/AccountMenu.tsx b/frontend/src/auth/AccountMenu.tsx
index be691e5d..a679973a 100644
--- a/frontend/src/auth/AccountMenu.tsx
+++ b/frontend/src/auth/AccountMenu.tsx
@@ -82,7 +82,7 @@ const AccountMenu = () => {
{user.name}
{user.accountType === 'anonymous' ? (
-
+
) : null}
diff --git a/frontend/src/translations/locales/ar-SA.json b/frontend/src/translations/locales/ar-SA.json
index b7d013c9..7fa7bfb4 100644
--- a/frontend/src/translations/locales/ar-SA.json
+++ b/frontend/src/translations/locales/ar-SA.json
@@ -5,7 +5,8 @@
"leave": "غادر",
"summaryMode": "النّمط الملخّص",
"account": "حسابي",
- "adminPanel": "لوحة الإدارة"
+ "adminPanel": "لوحة الإدارة",
+ "anonymous": "مجهول"
},
"LanguagePicker": {
"header": "إختيار اللُّغة"
diff --git a/frontend/src/translations/locales/de-DE.json b/frontend/src/translations/locales/de-DE.json
index 618c73f5..16e3e594 100644
--- a/frontend/src/translations/locales/de-DE.json
+++ b/frontend/src/translations/locales/de-DE.json
@@ -5,7 +5,8 @@
"leave": "Verlassen",
"summaryMode": "Zusammenfassungsmodus",
"account": "Mein Konto",
- "adminPanel": "Administrationsbereich"
+ "adminPanel": "Administrationsbereich",
+ "anonymous": "Anonym"
},
"LanguagePicker": {
"header": "Sprache auswählen"
diff --git a/frontend/src/translations/locales/en-GB.json b/frontend/src/translations/locales/en-GB.json
index d383068a..6bfcd94a 100644
--- a/frontend/src/translations/locales/en-GB.json
+++ b/frontend/src/translations/locales/en-GB.json
@@ -5,7 +5,8 @@
"leave": "Leave",
"summaryMode": "Summary Mode",
"account": "My Account",
- "adminPanel": "Administration Panel"
+ "adminPanel": "Administration Panel",
+ "anonymous": "Anonymous"
},
"LanguagePicker": {
"header": "Choose a language"
diff --git a/frontend/src/translations/locales/es-ES.json b/frontend/src/translations/locales/es-ES.json
index c6506c4c..057bea2d 100644
--- a/frontend/src/translations/locales/es-ES.json
+++ b/frontend/src/translations/locales/es-ES.json
@@ -5,7 +5,8 @@
"leave": "Salir",
"summaryMode": "Modo resumido",
"account": "Mi cuenta",
- "adminPanel": "Panel de administración"
+ "adminPanel": "Panel de administración",
+ "anonymous": "Anónimo"
},
"LanguagePicker": {
"header": "Escoje un idioma"
diff --git a/frontend/src/translations/locales/fr-FR.json b/frontend/src/translations/locales/fr-FR.json
index 2dff2efe..29e143a4 100644
--- a/frontend/src/translations/locales/fr-FR.json
+++ b/frontend/src/translations/locales/fr-FR.json
@@ -5,7 +5,8 @@
"leave": "Sortir",
"summaryMode": "Mode Résumé",
"account": "Mon compte",
- "adminPanel": "Gestion des utilisateurs"
+ "adminPanel": "Gestion des utilisateurs",
+ "anonymous": "Anonyme"
},
"LanguagePicker": {
"header": "Changez de langue"
diff --git a/frontend/src/translations/locales/hu-HU.json b/frontend/src/translations/locales/hu-HU.json
index 471aa782..0d9a31f3 100644
--- a/frontend/src/translations/locales/hu-HU.json
+++ b/frontend/src/translations/locales/hu-HU.json
@@ -5,7 +5,8 @@
"leave": "Távozás",
"summaryMode": "Összesített mód",
"account": "Fiókom",
- "adminPanel": "Adminisztrációs panel"
+ "adminPanel": "Adminisztrációs panel",
+ "anonymous": ""
},
"LanguagePicker": {
"header": "Válassz nyelvet"
diff --git a/frontend/src/translations/locales/it-IT.json b/frontend/src/translations/locales/it-IT.json
index b0973237..6c898e76 100644
--- a/frontend/src/translations/locales/it-IT.json
+++ b/frontend/src/translations/locales/it-IT.json
@@ -5,7 +5,8 @@
"leave": "Abbandona",
"summaryMode": "Modalità sommario",
"account": "Il Mio Account",
- "adminPanel": "Pannello Di Amministrazione"
+ "adminPanel": "Pannello Di Amministrazione",
+ "anonymous": "Anonimo"
},
"LanguagePicker": {
"header": "Scegli una lingua"
diff --git a/frontend/src/translations/locales/ja-JP.json b/frontend/src/translations/locales/ja-JP.json
index 9a10de36..89ae5d74 100644
--- a/frontend/src/translations/locales/ja-JP.json
+++ b/frontend/src/translations/locales/ja-JP.json
@@ -5,7 +5,8 @@
"leave": "退室",
"summaryMode": "要約モード",
"account": "マイアカウント",
- "adminPanel": "管理パネル"
+ "adminPanel": "管理パネル",
+ "anonymous": "匿名です"
},
"LanguagePicker": {
"header": "言語を選択"
diff --git a/frontend/src/translations/locales/nl-NL.json b/frontend/src/translations/locales/nl-NL.json
index 208d4185..c6982f29 100644
--- a/frontend/src/translations/locales/nl-NL.json
+++ b/frontend/src/translations/locales/nl-NL.json
@@ -5,7 +5,8 @@
"leave": "Verlaten",
"summaryMode": "Samenvatting",
"account": "Mijn account",
- "adminPanel": "Beheer paneel"
+ "adminPanel": "Beheer paneel",
+ "anonymous": "Anoniem"
},
"LanguagePicker": {
"header": "Kies een taal"
diff --git a/frontend/src/translations/locales/pl-PL.json b/frontend/src/translations/locales/pl-PL.json
index a18d72b8..d5cf2e40 100644
--- a/frontend/src/translations/locales/pl-PL.json
+++ b/frontend/src/translations/locales/pl-PL.json
@@ -5,7 +5,8 @@
"leave": "Wyjdź",
"summaryMode": "Tryb Podsumowania",
"account": "Moje konto",
- "adminPanel": "Panel administracyjny"
+ "adminPanel": "Panel administracyjny",
+ "anonymous": "Anonimowe"
},
"LanguagePicker": {
"header": "Wybierz język"
diff --git a/frontend/src/translations/locales/pt-BR.json b/frontend/src/translations/locales/pt-BR.json
index f288e59a..265b362f 100644
--- a/frontend/src/translations/locales/pt-BR.json
+++ b/frontend/src/translations/locales/pt-BR.json
@@ -5,7 +5,8 @@
"leave": "Sair",
"summaryMode": "Modo Sumário",
"account": "Minha conta",
- "adminPanel": "Painel de Administração"
+ "adminPanel": "Painel de Administração",
+ "anonymous": "Anônimo"
},
"LanguagePicker": {
"header": "Escolha uma língua"
diff --git a/frontend/src/translations/locales/pt-PT.json b/frontend/src/translations/locales/pt-PT.json
index 86abd65b..e0328352 100644
--- a/frontend/src/translations/locales/pt-PT.json
+++ b/frontend/src/translations/locales/pt-PT.json
@@ -5,7 +5,8 @@
"leave": "Sair",
"summaryMode": "Modo de Resumo",
"account": "Minha conta",
- "adminPanel": "Painel de Administração"
+ "adminPanel": "Painel de Administração",
+ "anonymous": "Anônimo"
},
"LanguagePicker": {
"header": "Escolha um idioma"
diff --git a/frontend/src/translations/locales/uk-UA.json b/frontend/src/translations/locales/uk-UA.json
index 71240532..cd3e83e5 100644
--- a/frontend/src/translations/locales/uk-UA.json
+++ b/frontend/src/translations/locales/uk-UA.json
@@ -5,7 +5,8 @@
"leave": "Залишити",
"summaryMode": "Анонімний режим",
"account": "Особистий кабінет",
- "adminPanel": "Панель адміністрування"
+ "adminPanel": "Панель адміністрування",
+ "anonymous": "Анонімний"
},
"LanguagePicker": {
"header": "Виберіть мову"
diff --git a/frontend/src/translations/locales/zh-CN.json b/frontend/src/translations/locales/zh-CN.json
index 40c8e9e4..551f5563 100644
--- a/frontend/src/translations/locales/zh-CN.json
+++ b/frontend/src/translations/locales/zh-CN.json
@@ -5,7 +5,8 @@
"leave": "离开",
"summaryMode": "主旨模式",
"account": "我的帐户",
- "adminPanel": "管理面板"
+ "adminPanel": "管理面板",
+ "anonymous": "匿名的"
},
"LanguagePicker": {
"header": "切换语言"
diff --git a/frontend/src/translations/locales/zh-TW.json b/frontend/src/translations/locales/zh-TW.json
index 59c53651..d4b48751 100644
--- a/frontend/src/translations/locales/zh-TW.json
+++ b/frontend/src/translations/locales/zh-TW.json
@@ -5,7 +5,8 @@
"leave": "離開",
"summaryMode": "主旨模式",
"account": "我的賬戶",
- "adminPanel": "管理面板"
+ "adminPanel": "管理面板",
+ "anonymous": ""
},
"LanguagePicker": {
"header": "切換語言"
diff --git a/frontend/src/translations/useLanguage.ts b/frontend/src/translations/useLanguage.ts
index 66e34c3e..f6450d3f 100644
--- a/frontend/src/translations/useLanguage.ts
+++ b/frontend/src/translations/useLanguage.ts
@@ -14,6 +14,7 @@ type UseLanguageResult = [
export default function useLanguage(): UseLanguageResult {
const { i18n } = useTranslation();
const { user, setUser } = useContext(UserContext);
+ const hasUser = !!user;
const locale = i18n.language;
const language = useMemo(() => {
@@ -25,14 +26,14 @@ export default function useLanguage(): UseLanguageResult {
async (language: string) => {
trackEvent(`language/change/${language}` as TrackingEvent);
i18n.changeLanguage(language);
- if (user) {
+ if (hasUser) {
const updatedUser = await updateLanguage(language);
if (updatedUser) {
setUser(updatedUser);
}
}
},
- [user, setUser, i18n]
+ [hasUser, setUser, i18n]
);
return [language, handleChangeLanguage];
diff --git a/frontend/src/views/Demo.tsx b/frontend/src/views/Demo.tsx
index 72d29bda..425810d8 100644
--- a/frontend/src/views/Demo.tsx
+++ b/frontend/src/views/Demo.tsx
@@ -1,6 +1,6 @@
import styled from '@emotion/styled';
import { colors } from '@mui/material';
-import { anonymousLogin, createDemoGame, me, updateLanguage } from 'api';
+import { createDemoGame, me, updateLanguage } from 'api';
import UserContext from 'auth/Context';
import { useContext, useEffect } from 'react';
import { useSearchParams } from 'react-router-dom';
@@ -12,12 +12,17 @@ export default function Demo() {
const { setUser } = useContext(UserContext);
let [searchParams] = useSearchParams();
const twoLetter = searchParams.get('lang');
- const [, changeLanguage] = useLanguage();
+ const [currentLanguage, changeLanguage] = useLanguage();
const language = getLanguage(twoLetter || 'en');
+ useEffect(() => {
+ if (currentLanguage.locale !== language.locale) {
+ changeLanguage(language.locale);
+ }
+ }, [language.locale, currentLanguage.locale, changeLanguage]);
+
useEffect(() => {
async function fetch() {
- await anonymousLogin('Demo User');
trackEvent('register/demo');
let updatedUser = await me();
if (updatedUser?.language === null) {
@@ -30,8 +35,10 @@ export default function Demo() {
window.location.href = `/game/${session.id}`;
}
}
- fetch();
- }, [language.locale, setUser, changeLanguage]);
+ if (language.locale === currentLanguage.locale) {
+ fetch();
+ }
+ }, [language.locale, currentLanguage.locale, setUser, changeLanguage]);
return (
Preparing demo...
diff --git a/integration/cypress/e2e/test.cy.ts b/integration/cypress/e2e/test.cy.ts
index 433fbe6a..8caa0838 100644
--- a/integration/cypress/e2e/test.cy.ts
+++ b/integration/cypress/e2e/test.cy.ts
@@ -108,3 +108,26 @@ describe('Post workflow', () => {
cy.get('body', { timeout }).get('h1').should('contain', 'Welcome!');
});
});
+
+describe('Demo Workflow', () => {
+ beforeEach(() => {
+ cy.setCookie('wpcc', 'dismiss');
+ });
+
+ it('Should create a demo with the right language (French)', () => {
+ // Asking for a FR demo
+ cy.visit('/demo?lang=fr');
+
+ // It should contain the right post (in English)
+ cy.get('#content', { timeout }).should(
+ 'contain',
+ "I'm enjoying our new retrospective board!"
+ );
+
+ // But the UI must be in French
+ cy.get('#content', { timeout }).should(
+ 'contain',
+ 'Bienvenue dans cette démo'
+ );
+ });
+});