From 89a6c44c493c76cf76b01d6cb337f8e8f282efbb Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 29 Jul 2022 01:30:51 -0400 Subject: [PATCH] Easy way to check strings that are in the new system --- .../src/_i18n/CommonTranslations.ts | 19 ++++++++++++++++++- .../fakeyou/src/_i18n/FakeYouTranslations.ts | 6 ++++-- .../locales/en/tts/TtsModelListPage.json | 8 ++++++-- .../locales/es/tts/TtsModelListPage.json | 4 ++-- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/packages/components/src/_i18n/CommonTranslations.ts b/packages/components/src/_i18n/CommonTranslations.ts index 90ea25813b..4cd8abf236 100644 --- a/packages/components/src/_i18n/CommonTranslations.ts +++ b/packages/components/src/_i18n/CommonTranslations.ts @@ -110,5 +110,22 @@ function MergeDeepDictionary(dictA: DeepDictionary, dictB: DeepDictionary) : Dee return output; } +// Modify all the string leaves of a dictionary to include a prefix string +// This is useful to test if translations were updated using i18next. +function DebugPrefixLeaves(obj: DeepDictionary, prefix: string) : DeepDictionary { + let output : DeepDictionary = {}; -export { COMMON_TRANSLATIONS, MergeDeepDictionary } + Object.keys(obj).forEach((key : string) => { + const value = obj[key]; + if (typeof value === 'string') { + output[key] = `${prefix}${value}`; + } else { + output[key] = DebugPrefixLeaves(value, prefix); + } + }); + + return output; +} + + +export { COMMON_TRANSLATIONS, MergeDeepDictionary, DebugPrefixLeaves } diff --git a/packages/fakeyou/src/_i18n/FakeYouTranslations.ts b/packages/fakeyou/src/_i18n/FakeYouTranslations.ts index 6f08ddcbb5..87db6abaa2 100644 --- a/packages/fakeyou/src/_i18n/FakeYouTranslations.ts +++ b/packages/fakeyou/src/_i18n/FakeYouTranslations.ts @@ -1,4 +1,4 @@ -import { COMMON_TRANSLATIONS, MergeDeepDictionary } from '@storyteller/components/src/_i18n/CommonTranslations'; +import { COMMON_TRANSLATIONS, DebugPrefixLeaves, MergeDeepDictionary } from '@storyteller/components/src/_i18n/CommonTranslations'; // Use \u{00a0} =   character literal @@ -7,11 +7,13 @@ import { COMMON_TRANSLATIONS, MergeDeepDictionary } from '@storyteller/component import * as en from './locales/en'; import * as es from './locales/es'; -const NEW_TRANSLATIONS: any = { +let NEW_TRANSLATIONS: any = { en: { translation: en }, es: { translation: es }, } +NEW_TRANSLATIONS = DebugPrefixLeaves(NEW_TRANSLATIONS, '\u{2705} '); + // NB: These are the old translations. They should be phased out. const FAKEYOU_TRANSLATIONS: any = { // English: 46.6% Twitch (#1), 30+% FakeYou (#1) diff --git a/packages/fakeyou/src/_i18n/locales/en/tts/TtsModelListPage.json b/packages/fakeyou/src/_i18n/locales/en/tts/TtsModelListPage.json index 43ac1dcb77..ca3cddd8cf 100644 --- a/packages/fakeyou/src/_i18n/locales/en/tts/TtsModelListPage.json +++ b/packages/fakeyou/src/_i18n/locales/en/tts/TtsModelListPage.json @@ -1,4 +1,8 @@ { - "heroSubtitle": "Use FakeYou deep fake tech to say stuff with your favorite characters*", - "heroTitle": "Text to Speech*" + "heroButtons": { + "cloneVoice": "Clone My Voice!", + "signUp": "Sign Up" + }, + "heroSubtitle": "Use FakeYou deep fake tech to say stuff with your favorite characters", + "heroTitle": "Text to Speech" } \ No newline at end of file diff --git a/packages/fakeyou/src/_i18n/locales/es/tts/TtsModelListPage.json b/packages/fakeyou/src/_i18n/locales/es/tts/TtsModelListPage.json index 0b78151a7a..03b9fb8cd6 100644 --- a/packages/fakeyou/src/_i18n/locales/es/tts/TtsModelListPage.json +++ b/packages/fakeyou/src/_i18n/locales/es/tts/TtsModelListPage.json @@ -1,4 +1,4 @@ { - "heroSubtitle": "Usa FakeYou tecnologĂ­a falsa profunda para decir cosas con tus personajes favoritos*", - "heroTitle": "Texto a Voz*" + "heroSubtitle": "Usa FakeYou tecnologĂ­a falsa profunda para decir cosas con tus personajes favoritos", + "heroTitle": "Texto a Voz" } \ No newline at end of file