Refactoring translator to use "_" instead of "translator._".

This is shorter and pollutes less the code.
This commit is contained in:
David Négrier 2022-01-19 09:28:08 +01:00 committed by Alexis Faizeau
parent 1789f36a63
commit 51c3f1d972
34 changed files with 174 additions and 190 deletions

View File

@ -73,10 +73,12 @@ Example:
} }
``` ```
In the code you can use it like this: In the code you can translate using `translator.translate`, or the shortcut alias: `_`.
```js ```js
translator._('messages.coffe-machine.start'); import { _ } from "../../Translator/Translator";
console.log(_('messages.coffe-machine.start'));
``` ```
### Add a key with parameters ### Add a key with parameters
@ -99,7 +101,7 @@ Example:
In the code you can use it like this: In the code you can use it like this:
```js ```js
translator._('messages.coffe-machine.player-start', { _('messages.coffe-machine.player-start', {
playerName: "John" playerName: "John"
}); });
``` ```

View File

@ -5,7 +5,7 @@
import { get } from "svelte/store"; import { get } from "svelte/store";
import type { Unsubscriber } from "svelte/store"; import type { Unsubscriber } from "svelte/store";
import { onDestroy, onMount } from "svelte"; import { onDestroy, onMount } from "svelte";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
let HTMLAudioPlayer: HTMLAudioElement; let HTMLAudioPlayer: HTMLAudioElement;
let audioPlayerVolumeIcon: HTMLElement; let audioPlayerVolumeIcon: HTMLElement;
@ -145,7 +145,7 @@
</div> </div>
<div class="audio-manager-reduce-conversation"> <div class="audio-manager-reduce-conversation">
<label> <label>
{translator._("audio.manager.reduce")} {_("audio.manager.reduce")}
<input type="checkbox" bind:checked={decreaseWhileTalking} on:change={setDecrease} /> <input type="checkbox" bind:checked={decreaseWhileTalking} on:change={setDecrease} />
</label> </label>
<section class="audio-manager-file"> <section class="audio-manager-file">

View File

@ -5,7 +5,7 @@
import ChatElement from "./ChatElement.svelte"; import ChatElement from "./ChatElement.svelte";
import { afterUpdate, beforeUpdate, onMount } from "svelte"; import { afterUpdate, beforeUpdate, onMount } from "svelte";
import { HtmlUtils } from "../../WebRtc/HtmlUtils"; import { HtmlUtils } from "../../WebRtc/HtmlUtils";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
let listDom: HTMLElement; let listDom: HTMLElement;
let chatWindowElement: HTMLElement; let chatWindowElement: HTMLElement;
@ -46,7 +46,7 @@
<p class="close-icon" on:click={closeChat}>&times</p> <p class="close-icon" on:click={closeChat}>&times</p>
<section class="messagesList" bind:this={listDom}> <section class="messagesList" bind:this={listDom}>
<ul> <ul>
<li><p class="system-text">{translator._("chat.intro")}</p></li> <li><p class="system-text">{_("chat.intro")}</p></li>
{#each $chatMessagesStore as message, i} {#each $chatMessagesStore as message, i}
<li><ChatElement {message} line={i} /></li> <li><ChatElement {message} line={i} /></li>
{/each} {/each}

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { chatMessagesStore, chatInputFocusStore } from "../../Stores/ChatStore"; import { chatMessagesStore, chatInputFocusStore } from "../../Stores/ChatStore";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
export const handleForm = { export const handleForm = {
blur() { blur() {
@ -28,7 +28,7 @@
<input <input
type="text" type="text"
bind:value={newMessageText} bind:value={newMessageText}
placeholder={translator._("chat.enter")} placeholder={_("chat.enter")}
on:focus={onFocus} on:focus={onFocus}
on:blur={onBlur} on:blur={onBlur}
bind:this={inputElement} bind:this={inputElement}

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import type { PlayerInterface } from "../../Phaser/Game/PlayerInterface"; import type { PlayerInterface } from "../../Phaser/Game/PlayerInterface";
import { requestVisitCardsStore } from "../../Stores/GameStore"; import { requestVisitCardsStore } from "../../Stores/GameStore";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
export let player: PlayerInterface; export let player: PlayerInterface;
@ -15,10 +15,10 @@
<ul class="selectMenu" style="border-top: {player.color || 'whitesmoke'} 5px solid"> <ul class="selectMenu" style="border-top: {player.color || 'whitesmoke'} 5px solid">
<li> <li>
<button class="text-btn" disabled={!player.visitCardUrl} on:click={openVisitCard} <button class="text-btn" disabled={!player.visitCardUrl} on:click={openVisitCard}
>{translator._("chat.menu.visit-card")}</button >{_("chat.menu.visit-card")}</button
> >
</li> </li>
<li><button class="text-btn" disabled>{translator._("chat.menu.add-friend")}</button></li> <li><button class="text-btn" disabled>{_("chat.menu.add-friend")}</button></li>
</ul> </ul>
<style lang="scss"> <style lang="scss">

View File

@ -2,7 +2,7 @@
import type { Game } from "../../Phaser/Game/Game"; import type { Game } from "../../Phaser/Game/Game";
import { CustomizeScene, CustomizeSceneName } from "../../Phaser/Login/CustomizeScene"; import { CustomizeScene, CustomizeSceneName } from "../../Phaser/Login/CustomizeScene";
import { activeRowStore } from "../../Stores/CustomCharacterStore"; import { activeRowStore } from "../../Stores/CustomCharacterStore";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
export let game: Game; export let game: Game;
@ -35,7 +35,7 @@
<form class="customCharacterScene"> <form class="customCharacterScene">
<section class="text-center"> <section class="text-center">
<h2>{translator._("custom-character.title")}</h2> <h2>{_("custom-character.title")}</h2>
</section> </section>
<section class="action action-move"> <section class="action action-move">
<button <button
@ -54,12 +54,12 @@
<section class="action"> <section class="action">
{#if $activeRowStore === 0} {#if $activeRowStore === 0}
<button type="submit" class="customCharacterSceneFormBack nes-btn" on:click|preventDefault={previousScene} <button type="submit" class="customCharacterSceneFormBack nes-btn" on:click|preventDefault={previousScene}
>{translator._("custom-character.navigation.return")}</button >{_("custom-character.navigation.return")}</button
> >
{/if} {/if}
{#if $activeRowStore !== 0} {#if $activeRowStore !== 0}
<button type="submit" class="customCharacterSceneFormBack nes-btn" on:click|preventDefault={selectUp} <button type="submit" class="customCharacterSceneFormBack nes-btn" on:click|preventDefault={selectUp}
>{translator._("custom-character.navigation.back")} >{_("custom-character.navigation.back")}
<img src="resources/objects/arrow_up_black.png" alt="" /></button <img src="resources/objects/arrow_up_black.png" alt="" /></button
> >
{/if} {/if}
@ -67,7 +67,7 @@
<button <button
type="submit" type="submit"
class="customCharacterSceneFormSubmit nes-btn is-primary" class="customCharacterSceneFormSubmit nes-btn is-primary"
on:click|preventDefault={finish}>{translator._("custom-character.navigation.finish")}</button on:click|preventDefault={finish}>{_("custom-character.navigation.finish")}</button
> >
{/if} {/if}
{#if $activeRowStore !== 5} {#if $activeRowStore !== 5}
@ -75,7 +75,7 @@
type="submit" type="submit"
class="customCharacterSceneFormSubmit nes-btn is-primary" class="customCharacterSceneFormSubmit nes-btn is-primary"
on:click|preventDefault={selectDown} on:click|preventDefault={selectDown}
>{translator._("custom-character.navigation.next")} >{_("custom-character.navigation.next")}
<img src="resources/objects/arrow_down.png" alt="" /></button <img src="resources/objects/arrow_down.png" alt="" /></button
> >
{/if} {/if}

View File

@ -13,7 +13,7 @@
import cinemaCloseImg from "../images/cinema-close.svg"; import cinemaCloseImg from "../images/cinema-close.svg";
import cinemaImg from "../images/cinema.svg"; import cinemaImg from "../images/cinema.svg";
import microphoneImg from "../images/microphone.svg"; import microphoneImg from "../images/microphone.svg";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
export let game: Game; export let game: Game;
let selectedCamera: string | undefined = undefined; let selectedCamera: string | undefined = undefined;
@ -77,7 +77,7 @@
<form class="enableCameraScene" on:submit|preventDefault={submit}> <form class="enableCameraScene" on:submit|preventDefault={submit}>
<section class="text-center"> <section class="text-center">
<h2>{translator._("camera.enable.title")}</h2> <h2>{_("camera.enable.title")}</h2>
</section> </section>
{#if $localStreamStore.type === "success" && $localStreamStore.stream} {#if $localStreamStore.type === "success" && $localStreamStore.stream}
<video class="myCamVideoSetup" use:srcObject={$localStreamStore.stream} autoplay muted playsinline /> <video class="myCamVideoSetup" use:srcObject={$localStreamStore.stream} autoplay muted playsinline />
@ -122,7 +122,7 @@
{/if} {/if}
</section> </section>
<section class="action"> <section class="action">
<button type="submit" class="nes-btn is-primary letsgo">{translator._("camera.enable.start")}</button> <button type="submit" class="nes-btn is-primary letsgo">{_("camera.enable.start")}</button>
</section> </section>
</form> </form>

View File

@ -6,7 +6,7 @@ vim: ft=typescript
import followImg from "../images/follow.svg"; import followImg from "../images/follow.svg";
import { followStateStore, followRoleStore, followUsersStore } from "../../Stores/FollowStore"; import { followStateStore, followRoleStore, followUsersStore } from "../../Stores/FollowStore";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
const gameScene = gameManager.getCurrentGameScene(); const gameScene = gameManager.getCurrentGameScene();
@ -44,14 +44,14 @@ vim: ft=typescript
{#if $followStateStore === "requesting" && $followRoleStore === "follower"} {#if $followStateStore === "requesting" && $followRoleStore === "follower"}
<div class="interact-menu nes-container is-rounded"> <div class="interact-menu nes-container is-rounded">
<section class="interact-menu-title"> <section class="interact-menu-title">
<h2>{translator._("follow.interact-menu.title.follow", { leader: name($followUsersStore[0]) })}</h2> <h2>{_("follow.interact-menu.title.follow", { leader: name($followUsersStore[0]) })}</h2>
</section> </section>
<section class="interact-menu-action"> <section class="interact-menu-action">
<button type="button" class="nes-btn is-success" on:click|preventDefault={acceptFollowRequest} <button type="button" class="nes-btn is-success" on:click|preventDefault={acceptFollowRequest}
>{translator._("follow.interact-menu.yes")}</button >{_("follow.interact-menu.yes")}</button
> >
<button type="button" class="nes-btn is-error" on:click|preventDefault={reset} <button type="button" class="nes-btn is-error" on:click|preventDefault={reset}
>{translator._("follow.interact-menu.no")}</button >{_("follow.interact-menu.no")}</button
> >
</section> </section>
</div> </div>
@ -60,23 +60,23 @@ vim: ft=typescript
{#if $followStateStore === "ending"} {#if $followStateStore === "ending"}
<div class="interact-menu nes-container is-rounded"> <div class="interact-menu nes-container is-rounded">
<section class="interact-menu-title"> <section class="interact-menu-title">
<h2>{translator._("follow.interact-menu.title.interact")}</h2> <h2>{_("follow.interact-menu.title.interact")}</h2>
</section> </section>
{#if $followRoleStore === "follower"} {#if $followRoleStore === "follower"}
<section class="interact-menu-question"> <section class="interact-menu-question">
<p>{translator._("follow.interact-menu.stop.follower", { leader: name($followUsersStore[0]) })}</p> <p>{_("follow.interact-menu.stop.follower", { leader: name($followUsersStore[0]) })}</p>
</section> </section>
{:else if $followRoleStore === "leader"} {:else if $followRoleStore === "leader"}
<section class="interact-menu-question"> <section class="interact-menu-question">
<p>{translator._("follow.interact-menu.stop.leader")}</p> <p>{_("follow.interact-menu.stop.leader")}</p>
</section> </section>
{/if} {/if}
<section class="interact-menu-action"> <section class="interact-menu-action">
<button type="button" class="nes-btn is-success" on:click|preventDefault={reset} <button type="button" class="nes-btn is-success" on:click|preventDefault={reset}
>{translator._("follow.interact-menu.yes")}</button >{_("follow.interact-menu.yes")}</button
> >
<button type="button" class="nes-btn is-error" on:click|preventDefault={abortEnding} <button type="button" class="nes-btn is-error" on:click|preventDefault={abortEnding}
>{translator._("follow.interact-menu.no")}</button >{_("follow.interact-menu.no")}</button
> >
</section> </section>
</div> </div>
@ -86,21 +86,21 @@ vim: ft=typescript
<div class="interact-status nes-container is-rounded"> <div class="interact-status nes-container is-rounded">
<section class="interact-status"> <section class="interact-status">
{#if $followRoleStore === "follower"} {#if $followRoleStore === "follower"}
<p>{translator._("follow.interact-status.following", { leader: name($followUsersStore[0]) })}</p> <p>{_("follow.interact-status.following", { leader: name($followUsersStore[0]) })}</p>
{:else if $followUsersStore.length === 0} {:else if $followUsersStore.length === 0}
<p>{translator._("follow.interact-status.waiting-followers")}</p> <p>{_("follow.interact-status.waiting-followers")}</p>
{:else if $followUsersStore.length === 1} {:else if $followUsersStore.length === 1}
<p>{translator._("follow.interact-status.followed.one", { follower: name($followUsersStore[0]) })}</p> <p>{_("follow.interact-status.followed.one", { follower: name($followUsersStore[0]) })}</p>
{:else if $followUsersStore.length === 2} {:else if $followUsersStore.length === 2}
<p> <p>
{translator._("follow.interact-status.followed.one", { {_("follow.interact-status.followed.one", {
firstFollower: name($followUsersStore[0]), firstFollower: name($followUsersStore[0]),
secondFollower: name($followUsersStore[1]), secondFollower: name($followUsersStore[1]),
})} })}
</p> </p>
{:else} {:else}
<p> <p>
{translator._("follow.interact-status.followed.many", { {_("follow.interact-status.followed.many", {
followers: $followUsersStore.slice(0, -1).map(name).join(", "), followers: $followUsersStore.slice(0, -1).map(name).join(", "),
lastFollower: name($followUsersStore[$followUsersStore.length - 1]), lastFollower: name($followUsersStore[$followUsersStore.length - 1]),
})} })}

View File

@ -4,7 +4,7 @@
import firefoxImg from "./images/help-setting-camera-permission-firefox.png"; import firefoxImg from "./images/help-setting-camera-permission-firefox.png";
import chromeImg from "./images/help-setting-camera-permission-chrome.png"; import chromeImg from "./images/help-setting-camera-permission-chrome.png";
import { getNavigatorType, isAndroid as isAndroidFct, NavigatorType } from "../../WebRtc/DeviceUtils"; import { getNavigatorType, isAndroid as isAndroidFct, NavigatorType } from "../../WebRtc/DeviceUtils";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
let isAndroid = isAndroidFct(); let isAndroid = isAndroidFct();
let isFirefox = getNavigatorType() === NavigatorType.firefox; let isFirefox = getNavigatorType() === NavigatorType.firefox;
@ -25,13 +25,13 @@
transition:fly={{ y: -900, duration: 500 }} transition:fly={{ y: -900, duration: 500 }}
> >
<section> <section>
<h2>{translator._("camera.help.title")}</h2> <h2>{_("camera.help.title")}</h2>
<p class="err">{translator._("camera.help.permission-denied")}</p> <p class="err">{_("camera.help.permission-denied")}</p>
<p>{translator._("camera.help.content")}</p> <p>{_("camera.help.content")}</p>
<p> <p>
{#if isFirefox} {#if isFirefox}
<p class="err"> <p class="err">
{translator._("camera.help.firefox-content")} {_("camera.help.firefox-content")}
</p> </p>
<img src={firefoxImg} alt="" /> <img src={firefoxImg} alt="" />
{:else if isChrome && !isAndroid} {:else if isChrome && !isAndroid}
@ -41,10 +41,10 @@
</section> </section>
<section> <section>
<button class="helpCameraSettingsFormRefresh nes-btn" on:click|preventDefault={refresh} <button class="helpCameraSettingsFormRefresh nes-btn" on:click|preventDefault={refresh}
>{translator._("camera.help.refresh")}</button >{_("camera.help.refresh")}</button
> >
<button type="submit" class="helpCameraSettingsFormContinue nes-btn is-primary" on:click|preventDefault={close} <button type="submit" class="helpCameraSettingsFormContinue nes-btn is-primary" on:click|preventDefault={close}
>{translator._("camera.help.continue")}</button >{_("camera.help.continue")}</button
> >
</section> </section>
</form> </form>

View File

@ -4,7 +4,7 @@
import { DISPLAY_TERMS_OF_USE, MAX_USERNAME_LENGTH } from "../../Enum/EnvironmentVariable"; import { DISPLAY_TERMS_OF_USE, MAX_USERNAME_LENGTH } from "../../Enum/EnvironmentVariable";
import logoImg from "../images/logo.png"; import logoImg from "../images/logo.png";
import { gameManager } from "../../Phaser/Game/GameManager"; import { gameManager } from "../../Phaser/Game/GameManager";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
export let game: Game; export let game: Game;
@ -28,7 +28,7 @@
<img src={logoImg} alt="WorkAdventure logo" /> <img src={logoImg} alt="WorkAdventure logo" />
</section> </section>
<section class="text-center"> <section class="text-center">
<h2>{translator._("login.input.name.placeholder")}</h2> <h2>{_("login.input.name.placeholder")}</h2>
</section> </section>
<!-- svelte-ignore a11y-autofocus --> <!-- svelte-ignore a11y-autofocus -->
<input <input
@ -45,7 +45,7 @@
/> />
<section class="error-section"> <section class="error-section">
{#if name.trim() === "" && startValidating} {#if name.trim() === "" && startValidating}
<p class="err">{translator._("login.input.name.empty")}</p> <p class="err">{_("login.input.name.empty")}</p>
{/if} {/if}
</section> </section>
@ -53,12 +53,12 @@
<section class="terms-and-conditions"> <section class="terms-and-conditions">
<a style="display: none;" href="traduction">Need for traduction</a> <a style="display: none;" href="traduction">Need for traduction</a>
<p> <p>
{translator._("login.terms")} {_("login.terms")}
</p> </p>
</section> </section>
{/if} {/if}
<section class="action"> <section class="action">
<button type="submit" class="nes-btn is-primary loginSceneFormSubmit">{translator._("login.continue")}</button> <button type="submit" class="nes-btn is-primary loginSceneFormSubmit">{_("login.continue")}</button>
</section> </section>
</form> </form>

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { gameManager } from "../../Phaser/Game/GameManager"; import { gameManager } from "../../Phaser/Game/GameManager";
import { onMount } from "svelte"; import { onMount } from "svelte";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
let gameScene = gameManager.getCurrentGameScene(); let gameScene = gameManager.getCurrentGameScene();
@ -12,7 +12,7 @@
let mapName: string = ""; let mapName: string = "";
let mapLink: string = ""; let mapLink: string = "";
let mapDescription: string = ""; let mapDescription: string = "";
let mapCopyright: string = translator._("menu.about.copyrights.map.empty"); let mapCopyright: string = _("menu.about.copyrights.map.empty");
let tilesetCopyright: string[] = []; let tilesetCopyright: string[] = [];
let audioCopyright: string[] = []; let audioCopyright: string[] = [];
@ -63,37 +63,37 @@
</script> </script>
<div class="about-room-main"> <div class="about-room-main">
<h2>{translator._("menu.about.map-info")}</h2> <h2>{_("menu.about.map-info")}</h2>
<section class="container-overflow"> <section class="container-overflow">
<h3>{mapName}</h3> <h3>{mapName}</h3>
<p class="string-HTML">{mapDescription}</p> <p class="string-HTML">{mapDescription}</p>
{#if mapLink} {#if mapLink}
<p class="string-HTML"> <p class="string-HTML">
&gt; <a href={mapLink} target="_blank">{translator._("menu.about.map-link")}</a> &lt; &gt; <a href={mapLink} target="_blank">{_("menu.about.map-link")}</a> &lt;
</p> </p>
{/if} {/if}
<h3 class="nes-pointer hoverable" on:click={() => (expandedMapCopyright = !expandedMapCopyright)}> <h3 class="nes-pointer hoverable" on:click={() => (expandedMapCopyright = !expandedMapCopyright)}>
{translator._("menu.about.copyrights.map.title")} {_("menu.about.copyrights.map.title")}
</h3> </h3>
<p class="string-HTML" hidden={!expandedMapCopyright}>{mapCopyright}</p> <p class="string-HTML" hidden={!expandedMapCopyright}>{mapCopyright}</p>
<h3 class="nes-pointer hoverable" on:click={() => (expandedTilesetCopyright = !expandedTilesetCopyright)}> <h3 class="nes-pointer hoverable" on:click={() => (expandedTilesetCopyright = !expandedTilesetCopyright)}>
{translator._("menu.about.copyrights.tileset.title")} {_("menu.about.copyrights.tileset.title")}
</h3> </h3>
<section hidden={!expandedTilesetCopyright}> <section hidden={!expandedTilesetCopyright}>
{#each tilesetCopyright as copyright} {#each tilesetCopyright as copyright}
<p class="string-HTML">{copyright}</p> <p class="string-HTML">{copyright}</p>
{:else} {:else}
<p>{translator._("menu.about.copyrights.tileset.empty")}</p> <p>{_("menu.about.copyrights.tileset.empty")}</p>
{/each} {/each}
</section> </section>
<h3 class="nes-pointer hoverable" on:click={() => (expandedAudioCopyright = !expandedAudioCopyright)}> <h3 class="nes-pointer hoverable" on:click={() => (expandedAudioCopyright = !expandedAudioCopyright)}>
{translator._("menu.about.copyrights.audio.title")} {_("menu.about.copyrights.audio.title")}
</h3> </h3>
<section hidden={!expandedAudioCopyright}> <section hidden={!expandedAudioCopyright}>
{#each audioCopyright as copyright} {#each audioCopyright as copyright}
<p class="string-HTML">{copyright}</p> <p class="string-HTML">{copyright}</p>
{:else} {:else}
<p>{translator._("menu.about.copyrights.audio.empty")}</p> <p>{_("menu.about.copyrights.audio.empty")}</p>
{/each} {/each}
</section> </section>
</section> </section>

View File

@ -4,7 +4,7 @@
import { AdminMessageEventTypes } from "../../Connexion/AdminMessagesService"; import { AdminMessageEventTypes } from "../../Connexion/AdminMessagesService";
import uploadFile from "../images/music-file.svg"; import uploadFile from "../images/music-file.svg";
import type { PlayGlobalMessageInterface } from "../../Connexion/ConnexionModels"; import type { PlayGlobalMessageInterface } from "../../Connexion/ConnexionModels";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
interface EventTargetFiles extends EventTarget { interface EventTargetFiles extends EventTarget {
files: Array<File>; files: Array<File>;
@ -77,7 +77,7 @@
<img <img
class="nes-pointer" class="nes-pointer"
src={uploadFile} src={uploadFile}
alt={translator._("menu.global-audio.upload-info")} alt={_("menu.global-audio.upload-info")}
on:click|preventDefault={() => { on:click|preventDefault={() => {
fileInput.click(); fileInput.click();
}} }}
@ -86,7 +86,7 @@
<p>{fileName} : {fileSize}</p> <p>{fileName} : {fileSize}</p>
{/if} {/if}
{#if errorFile} {#if errorFile}
<p class="err">{translator._("menu.global-audio.error")}</p> <p class="err">{_("menu.global-audio.error")}</p>
{/if} {/if}
<input <input
type="file" type="file"

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { contactPageStore } from "../../Stores/MenuStore"; import { contactPageStore } from "../../Stores/MenuStore";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
function goToGettingStarted() { function goToGettingStarted() {
const sparkHost = "https://workadventu.re/getting-started"; const sparkHost = "https://workadventu.re/getting-started";
@ -16,18 +16,18 @@
<div class="create-map-main"> <div class="create-map-main">
<section class="container-overflow"> <section class="container-overflow">
<section> <section>
<h3>{translator._("menu.contact.getting-started.title")}</h3> <h3>{_("menu.contact.getting-started.title")}</h3>
<p>{translator._("menu.contact.getting-started.description")}</p> <p>{_("menu.contact.getting-started.description")}</p>
<button type="button" class="nes-btn is-primary" on:click={goToGettingStarted} <button type="button" class="nes-btn is-primary" on:click={goToGettingStarted}
>{translator._("menu.contact.getting-started.title")}</button >{_("menu.contact.getting-started.title")}</button
> >
</section> </section>
<section> <section>
<h3>{translator._("menu.contact.create-map.title")}</h3> <h3>{_("menu.contact.create-map.title")}</h3>
<p>{translator._("menu.contact.create-map.description")}</p> <p>{_("menu.contact.create-map.description")}</p>
<button type="button" class="nes-btn" on:click={goToBuildingMap} <button type="button" class="nes-btn" on:click={goToBuildingMap}
>{translator._("menu.contact.create-map.title")}</button >{_("menu.contact.create-map.title")}</button
> >
</section> </section>

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import TextGlobalMessage from "./TextGlobalMessage.svelte"; import TextGlobalMessage from "./TextGlobalMessage.svelte";
import AudioGlobalMessage from "./AudioGlobalMessage.svelte"; import AudioGlobalMessage from "./AudioGlobalMessage.svelte";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
let handleSendText: { sendTextMessage(broadcast: boolean): void }; let handleSendText: { sendTextMessage(broadcast: boolean): void };
let handleSendAudio: { sendAudioMessage(broadcast: boolean): Promise<void> }; let handleSendAudio: { sendAudioMessage(broadcast: boolean): Promise<void> };
@ -36,14 +36,14 @@
<button <button
type="button" type="button"
class="nes-btn {inputSendTextActive ? 'is-disabled' : ''}" class="nes-btn {inputSendTextActive ? 'is-disabled' : ''}"
on:click|preventDefault={activateInputText}>{translator._("menu.global-message.text")}</button on:click|preventDefault={activateInputText}>{_("menu.global-message.text")}</button
> >
</section> </section>
<section> <section>
<button <button
type="button" type="button"
class="nes-btn {uploadAudioActive ? 'is-disabled' : ''}" class="nes-btn {uploadAudioActive ? 'is-disabled' : ''}"
on:click|preventDefault={activateUploadAudio}>{translator._("menu.global-message.audio")}</button on:click|preventDefault={activateUploadAudio}>{_("menu.global-message.audio")}</button
> >
</section> </section>
</div> </div>
@ -58,12 +58,10 @@
<div class="global-message-footer"> <div class="global-message-footer">
<label> <label>
<input type="checkbox" class="nes-checkbox is-dark nes-pointer" bind:checked={broadcastToWorld} /> <input type="checkbox" class="nes-checkbox is-dark nes-pointer" bind:checked={broadcastToWorld} />
<span>{translator._("menu.global-message.warning")}</span> <span>{_("menu.global-message.warning")}</span>
</label> </label>
<section> <section>
<button class="nes-btn is-primary" on:click|preventDefault={send} <button class="nes-btn is-primary" on:click|preventDefault={send}>{_("menu.global-message.send")}</button>
>{translator._("menu.global-message.send")}</button
>
</section> </section>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
function copyLink() { function copyLink() {
const input: HTMLInputElement = document.getElementById("input-share-link") as HTMLInputElement; const input: HTMLInputElement = document.getElementById("input-share-link") as HTMLInputElement;
@ -23,18 +23,14 @@
<div class="guest-main"> <div class="guest-main">
<section class="container-overflow"> <section class="container-overflow">
<section class="share-url not-mobile"> <section class="share-url not-mobile">
<h3>{translator._("menu.invite.description")}</h3> <h3>{_("menu.invite.description")}</h3>
<input type="text" readonly id="input-share-link" value={location.toString()} /> <input type="text" readonly id="input-share-link" value={location.toString()} />
<button type="button" class="nes-btn is-primary" on:click={copyLink} <button type="button" class="nes-btn is-primary" on:click={copyLink}>{_("menu.invite.copy")}</button>
>{translator._("menu.invite.copy")}</button
>
</section> </section>
<section class="is-mobile"> <section class="is-mobile">
<h3>{translator._("menu.invite.description")}</h3> <h3>{_("menu.invite.description")}</h3>
<input type="hidden" readonly id="input-share-link" value={location.toString()} /> <input type="hidden" readonly id="input-share-link" value={location.toString()} />
<button type="button" class="nes-btn is-primary" on:click={shareLink} <button type="button" class="nes-btn is-primary" on:click={shareLink}>{_("menu.invite.share")}</button>
>{translator._("menu.invite.share")}</button
>
</section> </section>
</section> </section>
</div> </div>

View File

@ -18,7 +18,7 @@
import { get } from "svelte/store"; import { get } from "svelte/store";
import type { Unsubscriber } from "svelte/store"; import type { Unsubscriber } from "svelte/store";
import { sendMenuClickedEvent } from "../../Api/iframe/Ui/MenuItem"; import { sendMenuClickedEvent } from "../../Api/iframe/Ui/MenuItem";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
let activeSubMenu: string = SubMenusInterface.profile; let activeSubMenu: string = SubMenusInterface.profile;
let activeComponent: typeof ProfileSubMenu | typeof CustomSubMenu = ProfileSubMenu; let activeComponent: typeof ProfileSubMenu | typeof CustomSubMenu = ProfileSubMenu;
@ -92,7 +92,7 @@
function translateMenuName(menuName: string) { function translateMenuName(menuName: string) {
const nameFormatted = "menu.sub." + menuName.toLowerCase().replaceAll(" ", "-"); const nameFormatted = "menu.sub." + menuName.toLowerCase().replaceAll(" ", "-");
const translation = translator._(nameFormatted); const translation = _(nameFormatted);
return translation === nameFormatted ? menuName : translation; return translation === nameFormatted ? menuName : translation;
} }
@ -102,7 +102,7 @@
<div class="menu-container-main"> <div class="menu-container-main">
<div class="menu-nav-sidebar nes-container is-rounded" transition:fly={{ x: -1000, duration: 500 }}> <div class="menu-nav-sidebar nes-container is-rounded" transition:fly={{ x: -1000, duration: 500 }}>
<h2>{translator._("menu.title")}</h2> <h2>{_("menu.title")}</h2>
<nav> <nav>
{#each $subMenusStore as submenu} {#each $subMenusStore as submenu}
<button <button

View File

@ -9,7 +9,7 @@
import { get } from "svelte/store"; import { get } from "svelte/store";
import { ADMIN_URL } from "../../Enum/EnvironmentVariable"; import { ADMIN_URL } from "../../Enum/EnvironmentVariable";
import { showShareLinkMapModalStore } from "../../Stores/ModalStore"; import { showShareLinkMapModalStore } from "../../Stores/ModalStore";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
function showMenu() { function showMenu() {
menuVisiblilityStore.set(!get(menuVisiblilityStore)); menuVisiblilityStore.set(!get(menuVisiblilityStore));
@ -32,29 +32,19 @@
{#if $limitMapStore} {#if $limitMapStore}
<img <img
src={logoInvite} src={logoInvite}
alt={translator._("menu.icon.open.invite")} alt={_("menu.icon.open.invite")}
class="nes-pointer" class="nes-pointer"
on:click|preventDefault={showInvite} on:click|preventDefault={showInvite}
/> />
<img <img
src={logoRegister} src={logoRegister}
alt={translator._("menu.icon.open.register")} alt={_("menu.icon.open.register")}
class="nes-pointer" class="nes-pointer"
on:click|preventDefault={register} on:click|preventDefault={register}
/> />
{:else} {:else}
<img <img src={logoWA} alt={_("menu.icon.open.menu")} class="nes-pointer" on:click|preventDefault={showMenu} />
src={logoWA} <img src={logoTalk} alt={_("menu.icon.open.chat")} class="nes-pointer" on:click|preventDefault={showChat} />
alt={translator._("menu.icon.open.menu")}
class="nes-pointer"
on:click|preventDefault={showMenu}
/>
<img
src={logoTalk}
alt={translator._("menu.icon.open.chat")}
class="nes-pointer"
on:click|preventDefault={showChat}
/>
{/if} {/if}
</main> </main>

View File

@ -17,7 +17,7 @@
import btnProfileSubMenuCompanion from "../images/btn-menu-profile-companion.svg"; import btnProfileSubMenuCompanion from "../images/btn-menu-profile-companion.svg";
import Woka from "../Woka/Woka.svelte"; import Woka from "../Woka/Woka.svelte";
import Companion from "../Companion/Companion.svelte"; import Companion from "../Companion/Companion.svelte";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
function disableMenuStores() { function disableMenuStores() {
menuVisiblilityStore.set(false); menuVisiblilityStore.set(false);
@ -63,20 +63,20 @@
<div class="submenu"> <div class="submenu">
<section> <section>
<button type="button" class="nes-btn" on:click|preventDefault={openEditNameScene}> <button type="button" class="nes-btn" on:click|preventDefault={openEditNameScene}>
<img src={btnProfileSubMenuIdentity} alt={translator._("menu.profile.edit.name")} /> <img src={btnProfileSubMenuIdentity} alt={_("menu.profile.edit.name")} />
<span class="btn-hover">{translator._("menu.profile.edit.name")}</span> <span class="btn-hover">{_("menu.profile.edit.name")}</span>
</button> </button>
<button type="button" class="nes-btn" on:click|preventDefault={openEditSkinScene}> <button type="button" class="nes-btn" on:click|preventDefault={openEditSkinScene}>
<Woka userId={-1} placeholderSrc="" width="26px" height="26px" /> <Woka userId={-1} placeholderSrc="" width="26px" height="26px" />
<span class="btn-hover">{translator._("menu.profile.edit.woka")}</span> <span class="btn-hover">{_("menu.profile.edit.woka")}</span>
</button> </button>
<button type="button" class="nes-btn" on:click|preventDefault={openEditCompanionScene}> <button type="button" class="nes-btn" on:click|preventDefault={openEditCompanionScene}>
<Companion userId={-1} placeholderSrc={btnProfileSubMenuCompanion} width="26px" height="26px" /> <Companion userId={-1} placeholderSrc={btnProfileSubMenuCompanion} width="26px" height="26px" />
<span class="btn-hover">{translator._("menu.profile.edit.companion")}</span> <span class="btn-hover">{_("menu.profile.edit.companion")}</span>
</button> </button>
<button type="button" class="nes-btn" on:click|preventDefault={openEnableCameraScene}> <button type="button" class="nes-btn" on:click|preventDefault={openEnableCameraScene}>
<img src={btnProfileSubMenuCamera} alt={translator._("menu.profile.edit.camera")} /> <img src={btnProfileSubMenuCamera} alt={_("menu.profile.edit.camera")} />
<span class="btn-hover">{translator._("menu.profile.edit.camera")}</span> <span class="btn-hover">{_("menu.profile.edit.camera")}</span>
</button> </button>
</section> </section>
</div> </div>
@ -90,12 +90,12 @@
</section> </section>
<section> <section>
<button type="button" class="nes-btn" on:click|preventDefault={logOut} <button type="button" class="nes-btn" on:click|preventDefault={logOut}
>{translator._("menu.profile.logout")}</button >{_("menu.profile.logout")}</button
> >
</section> </section>
{:else} {:else}
<section> <section>
<a type="button" class="nes-btn" href="/login">{translator._("menu.profile.login")}</a> <a type="button" class="nes-btn" href="/login">{_("menu.profile.login")}</a>
</section> </section>
{/if} {/if}
</div> </div>

View File

@ -4,7 +4,7 @@
import { HtmlUtils } from "../../WebRtc/HtmlUtils"; import { HtmlUtils } from "../../WebRtc/HtmlUtils";
import { isMobile } from "../../Enum/EnvironmentVariable"; import { isMobile } from "../../Enum/EnvironmentVariable";
import { menuVisiblilityStore } from "../../Stores/MenuStore"; import { menuVisiblilityStore } from "../../Stores/MenuStore";
import { languages, translator } from "../../Translator/Translator"; import { languages, translator, _ } from "../../Translator/Translator";
let fullscreen: boolean = localUserStore.getFullscreen(); let fullscreen: boolean = localUserStore.getFullscreen();
let notification: boolean = localUserStore.getNotification() === "granted"; let notification: boolean = localUserStore.getNotification() === "granted";
@ -88,61 +88,61 @@
<div class="settings-main" on:submit|preventDefault={saveSetting}> <div class="settings-main" on:submit|preventDefault={saveSetting}>
<section> <section>
<h3>{translator._("menu.settings.game-quality.title")}</h3> <h3>{_("menu.settings.game-quality.title")}</h3>
<div class="nes-select is-dark"> <div class="nes-select is-dark">
<select bind:value={valueGame}> <select bind:value={valueGame}>
<option value={120} <option value={120}
>{isMobile() >{isMobile()
? translator._("menu.settings.game-quality.short.high") ? _("menu.settings.game-quality.short.high")
: translator._("menu.settings.game-quality.long.high")}</option : _("menu.settings.game-quality.long.high")}</option
> >
<option value={60} <option value={60}
>{isMobile() >{isMobile()
? translator._("menu.settings.game-quality.short.medium") ? _("menu.settings.game-quality.short.medium")
: translator._("menu.settings.game-quality.long.medium")}</option : _("menu.settings.game-quality.long.medium")}</option
> >
<option value={40} <option value={40}
>{isMobile() >{isMobile()
? translator._("menu.settings.game-quality.short.minimum") ? _("menu.settings.game-quality.short.minimum")
: translator._("menu.settings.game-quality.long.minimum")}</option : _("menu.settings.game-quality.long.minimum")}</option
> >
<option value={20} <option value={20}
>{isMobile() >{isMobile()
? translator._("menu.settings.game-quality.short.small") ? _("menu.settings.game-quality.short.small")
: translator._("menu.settings.game-quality.long.small")}</option : _("menu.settings.game-quality.long.small")}</option
> >
</select> </select>
</div> </div>
</section> </section>
<section> <section>
<h3>{translator._("menu.settings.video-quality.title")}</h3> <h3>{_("menu.settings.video-quality.title")}</h3>
<div class="nes-select is-dark"> <div class="nes-select is-dark">
<select bind:value={valueVideo}> <select bind:value={valueVideo}>
<option value={30} <option value={30}
>{isMobile() >{isMobile()
? translator._("menu.settings.video-quality.short.high") ? _("menu.settings.video-quality.short.high")
: translator._("menu.settings.video-quality.long.high")}</option : _("menu.settings.video-quality.long.high")}</option
> >
<option value={20} <option value={20}
>{isMobile() >{isMobile()
? translator._("menu.settings.video-quality.short.medium") ? _("menu.settings.video-quality.short.medium")
: translator._("menu.settings.video-quality.long.medium")}</option : _("menu.settings.video-quality.long.medium")}</option
> >
<option value={10} <option value={10}
>{isMobile() >{isMobile()
? translator._("menu.settings.video-quality.short.minimum") ? _("menu.settings.video-quality.short.minimum")
: translator._("menu.settings.video-quality.long.minimum")}</option : _("menu.settings.video-quality.long.minimum")}</option
> >
<option value={5} <option value={5}
>{isMobile() >{isMobile()
? translator._("menu.settings.video-quality.short.small") ? _("menu.settings.video-quality.short.small")
: translator._("menu.settings.video-quality.long.small")}</option : _("menu.settings.video-quality.long.small")}</option
> >
</select> </select>
</div> </div>
</section> </section>
<section> <section>
<h3>{translator._("menu.settings.language.title")}</h3> <h3>{_("menu.settings.language.title")}</h3>
<div class="nes-select is-dark"> <div class="nes-select is-dark">
<select class="languages-switcher" bind:value={valueLanguage}> <select class="languages-switcher" bind:value={valueLanguage}>
<!-- svelte-ignore missing-declaration --> <!-- svelte-ignore missing-declaration -->
@ -153,9 +153,9 @@
</div> </div>
</section> </section>
<section class="settings-section-save"> <section class="settings-section-save">
<p>{translator._("menu.settings.save.warning")}</p> <p>{_("menu.settings.save.warning")}</p>
<button type="button" class="nes-btn is-primary" on:click|preventDefault={saveSetting} <button type="button" class="nes-btn is-primary" on:click|preventDefault={saveSetting}
>{translator._("menu.settings.save.button")}</button >{_("menu.settings.save.button")}</button
> >
</section> </section>
<section class="settings-section-noSaveOption"> <section class="settings-section-noSaveOption">
@ -166,7 +166,7 @@
bind:checked={fullscreen} bind:checked={fullscreen}
on:change={changeFullscreen} on:change={changeFullscreen}
/> />
<span>{translator._("menu.settings.fullscreen")}</span> <span>{_("menu.settings.fullscreen")}</span>
</label> </label>
<label> <label>
<input <input
@ -175,7 +175,7 @@
bind:checked={notification} bind:checked={notification}
on:change={changeNotification} on:change={changeNotification}
/> />
<span>{translator._("menu.settings.notifications")}</span> <span>{_("menu.settings.notifications")}</span>
</label> </label>
<label> <label>
<input <input
@ -184,7 +184,7 @@
bind:checked={forceCowebsiteTrigger} bind:checked={forceCowebsiteTrigger}
on:change={changeForceCowebsiteTrigger} on:change={changeForceCowebsiteTrigger}
/> />
<span>{translator._("menu.settings.cowebsite-trigger")}</span> <span>{_("menu.settings.cowebsite-trigger")}</span>
</label> </label>
<label> <label>
<input <input
@ -193,7 +193,7 @@
bind:checked={ignoreFollowRequests} bind:checked={ignoreFollowRequests}
on:change={changeIgnoreFollowRequests} on:change={changeIgnoreFollowRequests}
/> />
<span>{translator._("menu.settings.ignore-follow-request")}</span> <span>{_("menu.settings.ignore-follow-request")}</span>
</label> </label>
</section> </section>
</div> </div>

View File

@ -5,7 +5,7 @@
import { AdminMessageEventTypes } from "../../Connexion/AdminMessagesService"; import { AdminMessageEventTypes } from "../../Connexion/AdminMessagesService";
import type { Quill } from "quill"; import type { Quill } from "quill";
import type { PlayGlobalMessageInterface } from "../../Connexion/ConnexionModels"; import type { PlayGlobalMessageInterface } from "../../Connexion/ConnexionModels";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
//toolbar //toolbar
const toolbarOptions = [ const toolbarOptions = [
@ -59,7 +59,7 @@
const { default: Quill } = await import("quill"); // eslint-disable-line @typescript-eslint/no-explicit-any const { default: Quill } = await import("quill"); // eslint-disable-line @typescript-eslint/no-explicit-any
quill = new Quill(QUILL_EDITOR, { quill = new Quill(QUILL_EDITOR, {
placeholder: translator._("menu.global-message.enter"), placeholder: _("menu.global-message.enter"),
theme: "snow", theme: "snow",
modules: { modules: {
toolbar: toolbarOptions, toolbar: toolbarOptions,

View File

@ -4,7 +4,7 @@
import SoundMeterWidget from "./SoundMeterWidget.svelte"; import SoundMeterWidget from "./SoundMeterWidget.svelte";
import { onDestroy } from "svelte"; import { onDestroy } from "svelte";
import { srcObject } from "./Video/utils"; import { srcObject } from "./Video/utils";
import { translator } from "../Translator/Translator"; import { _ } from "../Translator/Translator";
let stream: MediaStream | null; let stream: MediaStream | null;
@ -33,5 +33,5 @@
<SoundMeterWidget {stream} /> <SoundMeterWidget {stream} />
{/if} {/if}
</div> </div>
<div class="is-silent" class:hide={isSilent}>{translator._("camera.my.silent-zone")}</div> <div class="is-silent" class:hide={isSilent}>{_("camera.my.silent-zone")}</div>
</div> </div>

View File

@ -2,7 +2,7 @@
import { blackListManager } from "../../WebRtc/BlackListManager"; import { blackListManager } from "../../WebRtc/BlackListManager";
import { showReportScreenStore, userReportEmpty } from "../../Stores/ShowReportScreenStore"; import { showReportScreenStore, userReportEmpty } from "../../Stores/ShowReportScreenStore";
import { onMount } from "svelte"; import { onMount } from "svelte";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
export let userUUID: string | undefined; export let userUUID: string | undefined;
export let userName: string; export let userName: string;
@ -30,10 +30,10 @@
</script> </script>
<div class="block-container"> <div class="block-container">
<h3>{translator._("report.block.title")}</h3> <h3>{_("report.block.title")}</h3>
<p>{translator._("report.block.content", { userName })}</p> <p>{_("report.block.content", { userName })}</p>
<button type="button" class="nes-btn is-error" on:click|preventDefault={blockUser}> <button type="button" class="nes-btn is-error" on:click|preventDefault={blockUser}>
{userIsBlocked ? translator._("report.block.unblock") : translator._("report.block.block")} {userIsBlocked ? _("report.block.unblock") : _("report.block.block")}
</button> </button>
</div> </div>

View File

@ -7,7 +7,7 @@
import { playersStore } from "../../Stores/PlayersStore"; import { playersStore } from "../../Stores/PlayersStore";
import { connectionManager } from "../../Connexion/ConnectionManager"; import { connectionManager } from "../../Connexion/ConnectionManager";
import { get } from "svelte/store"; import { get } from "svelte/store";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
let blockActive = true; let blockActive = true;
let reportActive = !blockActive; let reportActive = !blockActive;
@ -60,7 +60,7 @@
<div class="report-menu-main nes-container is-rounded"> <div class="report-menu-main nes-container is-rounded">
<section class="report-menu-title"> <section class="report-menu-title">
<h2>{translator._("moderate.title", { userName })}</h2> <h2>{_("moderate.title", { userName })}</h2>
<section class="justify-center"> <section class="justify-center">
<button type="button" class="nes-btn" on:click|preventDefault={close}>X</button> <button type="button" class="nes-btn" on:click|preventDefault={close}>X</button>
</section> </section>
@ -70,14 +70,14 @@
<button <button
type="button" type="button"
class="nes-btn {blockActive ? 'is-disabled' : ''}" class="nes-btn {blockActive ? 'is-disabled' : ''}"
on:click|preventDefault={activateBlock}>{translator._("moderate.block")}</button on:click|preventDefault={activateBlock}>{_("moderate.block")}</button
> >
</section> </section>
<section class="justify-center"> <section class="justify-center">
<button <button
type="button" type="button"
class="nes-btn {reportActive ? 'is-disabled' : ''}" class="nes-btn {reportActive ? 'is-disabled' : ''}"
on:click|preventDefault={activateReport}>{translator._("moderate.report")}</button on:click|preventDefault={activateReport}>{_("moderate.report")}</button
> >
</section> </section>
</section> </section>
@ -87,7 +87,7 @@
{:else if reportActive} {:else if reportActive}
<ReportSubMenu {userUUID} /> <ReportSubMenu {userUUID} />
{:else} {:else}
<p>{translator._("moderate.no-select")}</p> <p>{_("moderate.no-select")}</p>
{/if} {/if}
</section> </section>
</div> </div>

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { showReportScreenStore, userReportEmpty } from "../../Stores/ShowReportScreenStore"; import { showReportScreenStore, userReportEmpty } from "../../Stores/ShowReportScreenStore";
import { gameManager } from "../../Phaser/Game/GameManager"; import { gameManager } from "../../Phaser/Game/GameManager";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
export let userUUID: string | undefined; export let userUUID: string | undefined;
let reportMessage: string; let reportMessage: string;
@ -23,20 +23,18 @@
</script> </script>
<div class="report-container-main"> <div class="report-container-main">
<h3>{translator._("report.title")}</h3> <h3>{_("report.title")}</h3>
<p>{translator._("report.message")}</p> <p>{_("report.message")}</p>
<form> <form>
<section> <section>
<label> <label>
<span>{translator._("report.message.title")}</span> <span>{_("report.message.title")}</span>
<textarea type="text" class="nes-textarea" bind:value={reportMessage} /> <textarea type="text" class="nes-textarea" bind:value={reportMessage} />
</label> </label>
<p hidden={hiddenError}>{translator._("report.message.empty")}</p> <p hidden={hiddenError}>{_("report.message.empty")}</p>
</section> </section>
<section> <section>
<button type="submit" class="nes-btn is-error" on:click={submitReport} <button type="submit" class="nes-btn is-error" on:click={submitReport}>{_("report.submit")}</button>
>{translator._("report.submit")}</button
>
</section> </section>
</form> </form>
</div> </div>

View File

@ -1,7 +1,7 @@
<script lang="typescript"> <script lang="typescript">
import type { Game } from "../../Phaser/Game/Game"; import type { Game } from "../../Phaser/Game/Game";
import { SelectCompanionScene, SelectCompanionSceneName } from "../../Phaser/Login/SelectCompanionScene"; import { SelectCompanionScene, SelectCompanionSceneName } from "../../Phaser/Login/SelectCompanionScene";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
export let game: Game; export let game: Game;
@ -26,7 +26,7 @@
<form class="selectCompanionScene"> <form class="selectCompanionScene">
<section class="text-center"> <section class="text-center">
<h2>{translator._("companion.select.title")}</h2> <h2>{_("companion.select.title")}</h2>
<button class="selectCharacterButton selectCharacterButtonLeft nes-btn" on:click|preventDefault={selectLeft}> <button class="selectCharacterButton selectCharacterButtonLeft nes-btn" on:click|preventDefault={selectLeft}>
&lt; &lt;
</button> </button>
@ -36,12 +36,12 @@
</section> </section>
<section class="action"> <section class="action">
<button href="/" class="selectCompanionSceneFormBack nes-btn" on:click|preventDefault={noCompanion} <button href="/" class="selectCompanionSceneFormBack nes-btn" on:click|preventDefault={noCompanion}
>{translator._("companion.select.any")}</button >{_("companion.select.any")}</button
> >
<button <button
type="submit" type="submit"
class="selectCompanionSceneFormSubmit nes-btn is-primary" class="selectCompanionSceneFormSubmit nes-btn is-primary"
on:click|preventDefault={selectCompanion}>{translator._("companion.select.continue")}</button on:click|preventDefault={selectCompanion}>{_("companion.select.continue")}</button
> >
</section> </section>
</form> </form>

View File

@ -3,7 +3,7 @@
import { onMount } from "svelte"; import { onMount } from "svelte";
import type { Message } from "../../Stores/TypeMessageStore/MessageStore"; import type { Message } from "../../Stores/TypeMessageStore/MessageStore";
import { banMessageStore } from "../../Stores/TypeMessageStore/BanMessageStore"; import { banMessageStore } from "../../Stores/TypeMessageStore/BanMessageStore";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
export let message: Message; export let message: Message;
@ -39,7 +39,7 @@
> >
<h2 class="title-ban-message"> <h2 class="title-ban-message">
<img src="resources/logos/report.svg" alt="***" /> <img src="resources/logos/report.svg" alt="***" />
{translator._("important-message")} {_("important-message")}
<img src="resources/logos/report.svg" alt="***" /> <img src="resources/logos/report.svg" alt="***" />
</h2> </h2>
<div class="content-ban-message"> <div class="content-ban-message">

View File

@ -3,7 +3,7 @@
import megaphoneImg from "./images/megaphone.svg"; import megaphoneImg from "./images/megaphone.svg";
import { soundPlayingStore } from "../../Stores/SoundPlayingStore"; import { soundPlayingStore } from "../../Stores/SoundPlayingStore";
import { afterUpdate } from "svelte"; import { afterUpdate } from "svelte";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
export let url: string; export let url: string;
let audio: HTMLAudioElement; let audio: HTMLAudioElement;
@ -19,7 +19,7 @@
<div class="audio-playing" transition:fly={{ x: 210, duration: 500 }}> <div class="audio-playing" transition:fly={{ x: 210, duration: 500 }}>
<img src={megaphoneImg} alt="Audio playing" /> <img src={megaphoneImg} alt="Audio playing" />
<p>{translator._("audio.message")}</p> <p>{_("audio.message")}</p>
<audio bind:this={audio} src={url} on:ended={soundEnded}> <audio bind:this={audio} src={url} on:ended={soundEnded}>
<track kind="captions" /> <track kind="captions" />
</audio> </audio>

View File

@ -2,7 +2,7 @@
import { fly } from "svelte/transition"; import { fly } from "svelte/transition";
import { requestVisitCardsStore } from "../../Stores/GameStore"; import { requestVisitCardsStore } from "../../Stores/GameStore";
import { onMount } from "svelte"; import { onMount } from "svelte";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
export let visitCardUrl: string; export let visitCardUrl: string;
let w = "500px"; let w = "500px";
@ -41,8 +41,7 @@
/> />
{#if !hidden} {#if !hidden}
<div class="buttonContainer"> <div class="buttonContainer">
<button class="nes-btn is-popUpElement" on:click={closeCard}>{translator._("menu.visit-card.close")}</button <button class="nes-btn is-popUpElement" on:click={closeCard}>{_("menu.visit-card.close")}</button>
>
</div> </div>
{/if} {/if}
</section> </section>

View File

@ -2,7 +2,7 @@
import { fly } from "svelte/transition"; import { fly } from "svelte/transition";
import { userIsAdminStore, limitMapStore } from "../../Stores/GameStore"; import { userIsAdminStore, limitMapStore } from "../../Stores/GameStore";
import { ADMIN_URL } from "../../Enum/EnvironmentVariable"; import { ADMIN_URL } from "../../Enum/EnvironmentVariable";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
const upgradeLink = ADMIN_URL + "/pricing"; const upgradeLink = ADMIN_URL + "/pricing";
const registerLink = ADMIN_URL + "/second-step-register"; const registerLink = ADMIN_URL + "/second-step-register";
@ -10,17 +10,17 @@
<main class="warningMain" transition:fly={{ y: -200, duration: 500 }}> <main class="warningMain" transition:fly={{ y: -200, duration: 500 }}>
{#if $userIsAdminStore} {#if $userIsAdminStore}
<h2>{translator._("warning.title")}</h2> <h2>{_("warning.title")}</h2>
<p> <p>
{translator._("warning.content", { upgradeLink })} {_("warning.content", { upgradeLink })}
</p> </p>
{:else if $limitMapStore} {:else if $limitMapStore}
<p> <p>
This map is available for 2 days. You can register your domain <a href={registerLink}>here</a>! This map is available for 2 days. You can register your domain <a href={registerLink}>here</a>!
</p> </p>
{:else} {:else}
<h2>{translator._("warning.title")}</h2> <h2>{_("warning.title")}</h2>
<p>{translator._("warning.limit")}</p> <p>{_("warning.limit")}</p>
{/if} {/if}
</main> </main>

View File

@ -1,7 +1,7 @@
<script lang="typescript"> <script lang="typescript">
import type { Game } from "../../Phaser/Game/Game"; import type { Game } from "../../Phaser/Game/Game";
import { SelectCharacterScene, SelectCharacterSceneName } from "../../Phaser/Login/SelectCharacterScene"; import { SelectCharacterScene, SelectCharacterSceneName } from "../../Phaser/Login/SelectCharacterScene";
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
export let game: Game; export let game: Game;
@ -26,7 +26,7 @@
<form class="selectCharacterScene"> <form class="selectCharacterScene">
<section class="text-center"> <section class="text-center">
<h2>{translator._("select-woka.title")}</h2> <h2>{_("select-woka.title")}</h2>
<button class="selectCharacterButton selectCharacterButtonLeft nes-btn" on:click|preventDefault={selectLeft}> <button class="selectCharacterButton selectCharacterButtonLeft nes-btn" on:click|preventDefault={selectLeft}>
&lt; &lt;
</button> </button>
@ -38,12 +38,12 @@
<button <button
type="submit" type="submit"
class="selectCharacterSceneFormSubmit nes-btn is-primary" class="selectCharacterSceneFormSubmit nes-btn is-primary"
on:click|preventDefault={cameraScene}>{translator._("select-woka.continue")}</button on:click|preventDefault={cameraScene}>{_("select-woka.continue")}</button
> >
<button <button
type="submit" type="submit"
class="selectCharacterSceneFormCustomYourOwnSubmit nes-btn" class="selectCharacterSceneFormCustomYourOwnSubmit nes-btn"
on:click|preventDefault={customizeScene}>{translator._("select-woka.customize")}</button on:click|preventDefault={customizeScene}>{_("select-woka.customize")}</button
> >
</section> </section>
</form> </form>

View File

@ -4,7 +4,7 @@ import { ErrorScene, ErrorSceneName } from "../Reconnecting/ErrorScene";
import { WAError } from "../Reconnecting/WAError"; import { WAError } from "../Reconnecting/WAError";
import { waScaleManager } from "../Services/WaScaleManager"; import { waScaleManager } from "../Services/WaScaleManager";
import { ReconnectingTextures } from "../Reconnecting/ReconnectingScene"; import { ReconnectingTextures } from "../Reconnecting/ReconnectingScene";
import { translator } from "../../Translator/Translator"; import { translator, _ } from "../../Translator/Translator";
export const EntrySceneName = "EntryScene"; export const EntrySceneName = "EntryScene";
@ -47,20 +47,20 @@ export class EntryScene extends Scene {
if (err.response && err.response.status == 404) { if (err.response && err.response.status == 404) {
ErrorScene.showError( ErrorScene.showError(
new WAError( new WAError(
translator._("error.access-link.title"), _("error.access-link.title"),
translator._("error.access-link.sub-title"), _("error.access-link.sub-title"),
translator._("error.access-link.details") _("error.access-link.details")
), ),
this.scene this.scene
); );
} else if (err.response && err.response.status == 403) { } else if (err.response && err.response.status == 403) {
ErrorScene.showError( ErrorScene.showError(
new WAError( new WAError(
translator._("error.connection-rejected.title"), _("error.connection-rejected.title"),
translator._("error.connection-rejected.sub-title", { _("error.connection-rejected.sub-title", {
error: err.response.data ? ". \n\r \n\r" + `${err.response.data}` : "", error: err.response.data ? ". \n\r \n\r" + `${err.response.data}` : "",
}), }),
translator._("error.connection-rejected.details") _("error.connection-rejected.details")
), ),
this.scene this.scene
); );

View File

@ -1,4 +1,4 @@
import { translator } from "../../Translator/Translator"; import { _ } from "../../Translator/Translator";
import { TextField } from "../Components/TextField"; import { TextField } from "../Components/TextField";
import Image = Phaser.GameObjects.Image; import Image = Phaser.GameObjects.Image;
import Sprite = Phaser.GameObjects.Sprite; import Sprite = Phaser.GameObjects.Sprite;
@ -39,7 +39,7 @@ export class ReconnectingScene extends Phaser.Scene {
this, this,
this.game.renderer.width / 2, this.game.renderer.width / 2,
this.game.renderer.height / 2, this.game.renderer.height / 2,
translator._("connection-lost") _("connection-lost")
); );
const cat = this.add.sprite(this.game.renderer.width / 2, this.game.renderer.height / 2 - 32, "cat"); const cat = this.add.sprite(this.game.renderer.width / 2, this.game.renderer.height / 2 - 32, "cat");

View File

@ -226,7 +226,7 @@ class Translator {
* @param {TranslationParams} params Tags to replace by value * @param {TranslationParams} params Tags to replace by value
* @returns {string} Translation formatted * @returns {string} Translation formatted
*/ */
public _(key: string, params?: TranslationParams): string { public translate(key: string, params?: TranslationParams): string {
const currentLanguageValue = this.getObjectValueByPath(key, this.currentLanguageObject); const currentLanguageValue = this.getObjectValueByPath(key, this.currentLanguageObject);
if (currentLanguageValue) { if (currentLanguageValue) {
@ -251,3 +251,4 @@ class Translator {
export const languages: LanguageFound[] = LANGUAGES; export const languages: LanguageFound[] = LANGUAGES;
export const translator = new Translator(); export const translator = new Translator();
export const _ = translator.translate.bind(translator);

View File

@ -13,7 +13,7 @@ import { layoutManagerActionStore, layoutManagerVisibilityStore } from "../Store
import { get } from "svelte/store"; import { get } from "svelte/store";
import { localUserStore } from "../Connexion/LocalUserStore"; import { localUserStore } from "../Connexion/LocalUserStore";
import { MediaStreamConstraintsError } from "../Stores/Errors/MediaStreamConstraintsError"; import { MediaStreamConstraintsError } from "../Stores/Errors/MediaStreamConstraintsError";
import { translator } from "../Translator/Translator"; import { _ } from "../Translator/Translator";
export class MediaManager { export class MediaManager {
startScreenSharingCallBacks: Set<StartScreenSharingCallback> = new Set<StartScreenSharingCallback>(); startScreenSharingCallBacks: Set<StartScreenSharingCallback> = new Set<StartScreenSharingCallback>();
@ -30,7 +30,7 @@ export class MediaManager {
layoutManagerActionStore.addAction({ layoutManagerActionStore.addAction({
uuid: "cameraAccessDenied", uuid: "cameraAccessDenied",
type: "warning", type: "warning",
message: translator._("warning.access-denied.camera"), message: _("warning.access-denied.camera"),
callback: () => { callback: () => {
helpCameraSettingsVisibleStore.set(true); helpCameraSettingsVisibleStore.set(true);
}, },
@ -51,7 +51,7 @@ export class MediaManager {
layoutManagerActionStore.addAction({ layoutManagerActionStore.addAction({
uuid: "screenSharingAccessDenied", uuid: "screenSharingAccessDenied",
type: "warning", type: "warning",
message: translator._("warning.access-denied.screen-sharing"), message: _("warning.access-denied.screen-sharing"),
callback: () => { callback: () => {
helpCameraSettingsVisibleStore.set(true); helpCameraSettingsVisibleStore.set(true);
}, },