diff --git a/docs/dev/how-to-translate.md b/docs/dev/how-to-translate.md index 86fd5129..77cbe3f4 100644 --- a/docs/dev/how-to-translate.md +++ b/docs/dev/how-to-translate.md @@ -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 -translator._('messages.coffe-machine.start'); +import { _ } from "../../Translator/Translator"; + +console.log(_('messages.coffe-machine.start')); ``` ### Add a key with parameters @@ -99,7 +101,7 @@ Example: In the code you can use it like this: ```js -translator._('messages.coffe-machine.player-start', { +_('messages.coffe-machine.player-start', { playerName: "John" }); -``` \ No newline at end of file +``` diff --git a/front/src/Components/AudioManager/AudioManager.svelte b/front/src/Components/AudioManager/AudioManager.svelte index 5bf02fc9..aab2747e 100644 --- a/front/src/Components/AudioManager/AudioManager.svelte +++ b/front/src/Components/AudioManager/AudioManager.svelte @@ -5,7 +5,7 @@ import { get } from "svelte/store"; import type { Unsubscriber } from "svelte/store"; import { onDestroy, onMount } from "svelte"; - import { translator } from "../../Translator/Translator"; + import { _ } from "../../Translator/Translator"; let HTMLAudioPlayer: HTMLAudioElement; let audioPlayerVolumeIcon: HTMLElement; @@ -145,7 +145,7 @@
diff --git a/front/src/Components/Chat/Chat.svelte b/front/src/Components/Chat/Chat.svelte index 2e60e43e..5f66837b 100644 --- a/front/src/Components/Chat/Chat.svelte +++ b/front/src/Components/Chat/Chat.svelte @@ -5,7 +5,7 @@ import ChatElement from "./ChatElement.svelte"; import { afterUpdate, beforeUpdate, onMount } from "svelte"; import { HtmlUtils } from "../../WebRtc/HtmlUtils"; - import { translator } from "../../Translator/Translator"; + import { _ } from "../../Translator/Translator"; let listDom: HTMLElement; let chatWindowElement: HTMLElement; @@ -46,7 +46,7 @@

×

    -
  • {translator._("chat.intro")}

  • +
  • {_("chat.intro")}

  • {#each $chatMessagesStore as message, i}
  • {/each} diff --git a/front/src/Components/Chat/ChatMessageForm.svelte b/front/src/Components/Chat/ChatMessageForm.svelte index 6853d669..345c4b7d 100644 --- a/front/src/Components/Chat/ChatMessageForm.svelte +++ b/front/src/Components/Chat/ChatMessageForm.svelte @@ -1,6 +1,6 @@
    -

    {translator._("menu.about.map-info")}

    +

    {_("menu.about.map-info")}

    {mapName}

    {mapDescription}

    {#if mapLink}

    - > {translator._("menu.about.map-link")} < + > {_("menu.about.map-link")} <

    {/if}

    (expandedMapCopyright = !expandedMapCopyright)}> - {translator._("menu.about.copyrights.map.title")} + {_("menu.about.copyrights.map.title")}

    (expandedTilesetCopyright = !expandedTilesetCopyright)}> - {translator._("menu.about.copyrights.tileset.title")} + {_("menu.about.copyrights.tileset.title")}

    (expandedAudioCopyright = !expandedAudioCopyright)}> - {translator._("menu.about.copyrights.audio.title")} + {_("menu.about.copyrights.audio.title")}

    diff --git a/front/src/Components/Menu/AudioGlobalMessage.svelte b/front/src/Components/Menu/AudioGlobalMessage.svelte index edc9568d..12f7a848 100644 --- a/front/src/Components/Menu/AudioGlobalMessage.svelte +++ b/front/src/Components/Menu/AudioGlobalMessage.svelte @@ -4,7 +4,7 @@ import { AdminMessageEventTypes } from "../../Connexion/AdminMessagesService"; import uploadFile from "../images/music-file.svg"; import type { PlayGlobalMessageInterface } from "../../Connexion/ConnexionModels"; - import { translator } from "../../Translator/Translator"; + import { _ } from "../../Translator/Translator"; interface EventTargetFiles extends EventTarget { files: Array; @@ -77,7 +77,7 @@ {translator._("menu.global-audio.upload-info")} { fileInput.click(); }} @@ -86,7 +86,7 @@

    {fileName} : {fileSize}

    {/if} {#if errorFile} -

    {translator._("menu.global-audio.error")}

    +

    {_("menu.global-audio.error")}

    {/if} import { contactPageStore } from "../../Stores/MenuStore"; - import { translator } from "../../Translator/Translator"; + import { _ } from "../../Translator/Translator"; function goToGettingStarted() { const sparkHost = "https://workadventu.re/getting-started"; @@ -16,18 +16,18 @@
    -

    {translator._("menu.contact.getting-started.title")}

    -

    {translator._("menu.contact.getting-started.description")}

    +

    {_("menu.contact.getting-started.title")}

    +

    {_("menu.contact.getting-started.description")}

    {_("menu.contact.getting-started.title")}
    -

    {translator._("menu.contact.create-map.title")}

    -

    {translator._("menu.contact.create-map.description")}

    +

    {_("menu.contact.create-map.title")}

    +

    {_("menu.contact.create-map.description")}

    {_("menu.contact.create-map.title")}
    diff --git a/front/src/Components/Menu/GlobalMessagesSubMenu.svelte b/front/src/Components/Menu/GlobalMessagesSubMenu.svelte index 654c0449..31bd674a 100644 --- a/front/src/Components/Menu/GlobalMessagesSubMenu.svelte +++ b/front/src/Components/Menu/GlobalMessagesSubMenu.svelte @@ -1,7 +1,7 @@
    -

    {translator._("report.block.title")}

    -

    {translator._("report.block.content", { userName })}

    +

    {_("report.block.title")}

    +

    {_("report.block.content", { userName })}

    diff --git a/front/src/Components/ReportMenu/ReportMenu.svelte b/front/src/Components/ReportMenu/ReportMenu.svelte index 0b482dc6..ab44e525 100644 --- a/front/src/Components/ReportMenu/ReportMenu.svelte +++ b/front/src/Components/ReportMenu/ReportMenu.svelte @@ -7,7 +7,7 @@ import { playersStore } from "../../Stores/PlayersStore"; import { connectionManager } from "../../Connexion/ConnectionManager"; import { get } from "svelte/store"; - import { translator } from "../../Translator/Translator"; + import { _ } from "../../Translator/Translator"; let blockActive = true; let reportActive = !blockActive; @@ -60,7 +60,7 @@
    -

    {translator._("moderate.title", { userName })}

    +

    {_("moderate.title", { userName })}

    @@ -70,14 +70,14 @@ {_("moderate.block")}
    {_("moderate.report")}
    @@ -87,7 +87,7 @@ {:else if reportActive} {:else} -

    {translator._("moderate.no-select")}

    +

    {_("moderate.no-select")}

    {/if}
diff --git a/front/src/Components/ReportMenu/ReportSubMenu.svelte b/front/src/Components/ReportMenu/ReportSubMenu.svelte index 20a38a9b..745816c1 100644 --- a/front/src/Components/ReportMenu/ReportSubMenu.svelte +++ b/front/src/Components/ReportMenu/ReportSubMenu.svelte @@ -1,7 +1,7 @@
-

{translator._("report.title")}

-

{translator._("report.message")}

+

{_("report.title")}

+

{_("report.message")}