From 2e90581b2da6e3588498d7fcbbc1800c3fb2204d Mon Sep 17 00:00:00 2001 From: Benedikt Magnus <magnus@magnuscraft.de> Date: Mon, 8 Nov 2021 12:45:29 +0100 Subject: [PATCH] Wichtel event phase localisation --- locale/de-DE.values.json | 8 +++++-- scripts/utility/localisation.ts | 38 ++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/locale/de-DE.values.json b/locale/de-DE.values.json index c8ec566..c0aa406 100644 --- a/locale/de-DE.values.json +++ b/locale/de-DE.values.json @@ -4,5 +4,9 @@ "giftTypeAll": "beides", "giftTypeNothing": "nichts", "no": "nein", - "yes": "ja" -} \ No newline at end of file + "yes": "ja", + "wichtelEventPhaseEnded": "Postwichteln", + "wichtelEventPhaseRegistration": "Registrierung", + "wichtelEventPhaseWaiting": "Präwichteln", + "wichtelEventPhaseWichteln": "Wichteln" +} diff --git a/scripts/utility/localisation.ts b/scripts/utility/localisation.ts index a7eacd6..8c9dca8 100644 --- a/scripts/utility/localisation.ts +++ b/scripts/utility/localisation.ts @@ -3,6 +3,7 @@ import * as fs from 'fs'; import Config from './config'; import GiftType from '../wichtelbot/types/giftType'; import TokenString from './tokenString'; +import WichtelEventPhase from './wichtelEvent'; export interface CommandInfo { @@ -95,6 +96,10 @@ interface Values giftTypeNothing: string; no: string; yes: string; + wichtelEventPhaseEnded: string, + wichtelEventPhaseRegistration: string, + wichtelEventPhaseWaiting: string, + wichtelEventPhaseWichteln: string, } export default abstract class Localisation @@ -148,27 +153,19 @@ export default abstract class Localisation public static translateGiftType (giftType: GiftType): string { - let result = ''; - switch (giftType) { case GiftType.Analogue: - result = Localisation._values.giftTypeAnalogue; - break; + return Localisation._values.giftTypeAnalogue; case GiftType.Digital: - result = Localisation._values.giftTypeDigital; - break; + return Localisation._values.giftTypeDigital; case GiftType.All: - result = Localisation._values.giftTypeAll; - break; + return Localisation._values.giftTypeAll; case GiftType.Nothing: - result = Localisation._values.giftTypeNothing; - break; + return Localisation._values.giftTypeNothing; default: throw TypeError('Invalid gift type to translate.'); } - - return result; } public static translateCountry (country: string): string @@ -180,4 +177,21 @@ export default abstract class Localisation return localisedCountry; } + + public static translateWichtelEventPhase (eventPhase: WichtelEventPhase): string + { + switch (eventPhase) + { + case WichtelEventPhase.Waiting: + return Localisation._values.wichtelEventPhaseWaiting; + case WichtelEventPhase.Registration: + return Localisation._values.wichtelEventPhaseRegistration; + case WichtelEventPhase.Wichteln: + return Localisation._values.wichtelEventPhaseWichteln; + case WichtelEventPhase.Ended: + return Localisation._values.wichtelEventPhaseEnded; + default: + throw TypeError('Invalid event phase to translate.'); + } + } } -- GitLab