diff --git a/front/src/Components/UI/ErrorDialog.svelte b/front/src/Components/UI/ErrorDialog.svelte index 4e03edb4..b0dc035c 100644 --- a/front/src/Components/UI/ErrorDialog.svelte +++ b/front/src/Components/UI/ErrorDialog.svelte @@ -1,5 +1,6 @@
Error
+{_("error.error")}
{error.message}
diff --git a/front/src/Connexion/AxiosUtils.ts b/front/src/Connexion/AxiosUtils.ts index f4cd160f..db6bcfbe 100644 --- a/front/src/Connexion/AxiosUtils.ts +++ b/front/src/Connexion/AxiosUtils.ts @@ -1,6 +1,7 @@ import axios from "axios"; import * as rax from "retry-axios"; import { errorStore } from "../Stores/ErrorStore"; +import { _ } from "../Translator/Translator"; /** * This instance of Axios will retry in case of an issue and display an error message as a HTML overlay. @@ -26,10 +27,13 @@ axiosWithRetry.defaults.raxConfig = { console.log(err); console.log(cfg); console.log(`Retry attempt #${cfg?.currentRetryAttempt} on URL '${err.config.url}'`); - errorStore.addErrorMessage("Unable to connect to WorkAdventure. Are you connected to internet?", { - closable: false, - id: "axios_retry", - }); + errorStore.addErrorMessage( + _("error.connection-retry.unable-to-connect-to-workAdventure-are-you-connected-to-internet"), + { + closable: false, + id: "axios_retry", + } + ); }, }; diff --git a/front/translations/en-US/error.en-US.json b/front/translations/en-US/error.en-US.json index d91d7dd0..23dde873 100644 --- a/front/translations/en-US/error.en-US.json +++ b/front/translations/en-US/error.en-US.json @@ -9,6 +9,10 @@ "title": "Connection rejected", "sub-title": "You cannot join the World. Try again later {{error}}.", "details": "If you want more information, you may contact administrator or contact us at: hello@workadventu.re" - } + }, + "connection-retry": { + "unable-to-connect-to-workAdventure-are-you-connected-to-internet": "Unable to connect to WorkAdventure. Are you connected to internet?" + }, + "error": "Error" } -} \ No newline at end of file +} diff --git a/front/translations/fr-FR/error.fr-FR.json b/front/translations/fr-FR/error.fr-FR.json index ea7679f4..bc120a6f 100644 --- a/front/translations/fr-FR/error.fr-FR.json +++ b/front/translations/fr-FR/error.fr-FR.json @@ -9,6 +9,10 @@ "title": "Connexion rejetée", "sub-title": "Vous ne pouvez pas rejoindre le monde. Réessayer plus tard {{error}}.", "details": "Si vous souhaitez obtenir de plus amples informations, vous pouvez contacter l'administrateur ou nous contacter à l'adresse suivante: hello@workadventu.re" - } + }, + "connection-retry": { + "unable-to-connect-to-workAdventure-are-you-connected-to-internet": "Impossible de se connecter à WorkAdventure. Etes vous connecté à Internet?" + }, + "error": "Erreur" } -} \ No newline at end of file +} diff --git a/tests/tests/reconnect.ts b/tests/tests/reconnect.ts index 62f92fd2..9b17e339 100644 --- a/tests/tests/reconnect.ts +++ b/tests/tests/reconnect.ts @@ -3,7 +3,7 @@ import {assertLogMessage} from "./utils/log"; const fs = require('fs'); const Docker = require('dockerode'); import { Selector } from 'testcafe'; -import {login} from "./utils/roles"; +import {login, resetLanguage} from "./utils/roles"; import {findContainer, rebootBack, rebootPusher, resetRedis, startContainer, stopContainer} from "./utils/containers"; fixture `Reconnection` @@ -16,6 +16,8 @@ test("Test that connection can succeed even if WorkAdventure starts while pusher const errorMessage = Selector('.error-div'); + await resetLanguage('en-US'); + await t .navigateTo('http://play.workadventure.localhost/_/global/maps.workadventure.localhost/tests/mousewheel.json') .expect(errorMessage.innerText).contains('Unable to connect to WorkAdventure') diff --git a/tests/tests/translate.ts b/tests/tests/translate.ts new file mode 100644 index 00000000..b0ba9c8a --- /dev/null +++ b/tests/tests/translate.ts @@ -0,0 +1,29 @@ +import { Selector } from 'testcafe'; +import {login} from "./utils/roles"; + +fixture `Translation` + .page `http://play.workadventure.localhost/_/global/maps.workadventure.localhost/tests/mousewheel.json`; + +test("Test that I can switch to French", async (t: TestController) => { + + const languageSelect = Selector('.languages-switcher'); + const languageOption = languageSelect.find('option'); + + await login(t, 'http://play.workadventure.localhost/_/global/maps.workadventure.localhost/tests/mousewheel.json'); + + await t.click('.menuIcon img:first-child') + .click(Selector('button').withText('Settings')) + .click('.languages-switcher') + .click(languageOption.withText('Français (France)')) + .click(Selector('button').withText('Save')) + + .click('.menuIcon img:first-child') + .expect(Selector('button').withText('Paramètres').innerText).contains('Paramètres'); + + t.ctx.passed = true; +}).after(async t => { + if (!t.ctx.passed) { + console.log("Test failed. Browser logs:") + console.log(await t.getBrowserConsoleMessages()); + } +}); diff --git a/tests/tests/utils/roles.ts b/tests/tests/utils/roles.ts index 7630f086..819446e7 100644 --- a/tests/tests/utils/roles.ts +++ b/tests/tests/utils/roles.ts @@ -1,6 +1,11 @@ -import { Role } from 'testcafe'; +import { Role, ClientFunction } from 'testcafe'; + +export const resetLanguage = ClientFunction((browserLanguage) => window.localStorage.setItem('language', browserLanguage)); + +export async function login(t: TestController, url: string, userName: string = "Alice", characterNumber: number = 2, browserLanguage: string|null = 'en-US') { + + await resetLanguage(browserLanguage); -export function login(t: TestController, url: string, userName: string = "Alice", characterNumber: number = 2) { t = t .navigateTo(url) .typeText('input[name="loginSceneName"]', userName)