From 407348a7e0c226366c3a2d6323651f700f0018e7 Mon Sep 17 00:00:00 2001 From: Kenny <27463495+Frontesque@users.noreply.github.com> Date: Mon, 8 Aug 2022 20:23:00 -0400 Subject: [PATCH] feat: :wheelchair: translation fallback 1/2 --- NUXT/plugins/language.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/NUXT/plugins/language.js b/NUXT/plugins/language.js index 818ac32..17d6ce9 100644 --- a/NUXT/plugins/language.js +++ b/NUXT/plugins/language.js @@ -35,8 +35,25 @@ function module(subPack, listPacks) { const selectedLanguage = localStorage.getItem("language") || "english"; const languagePack = packs[selectedLanguage]; + //--- Send Full Language Pack ---// if (!subPack) return languagePack; - return languagePack[subPack]; + //--- Allow Subpack Fallback ---// + let builtSubPack = new Object(); + for (const i in packs.english[subPack]) { + const englishEntry = packs.english[subPack][i]; + const entry = languagePack[subPack][i]; + + if (!entry) { + builtSubPack[i] = englishEntry; + } else { + builtSubPack[i] = entry; + } + + + } + //--- Return Built Subpack ---// + console.log("RETURNING:",builtSubPack) + return builtSubPack; } export default ({ app }, inject) => {