aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-07-06 02:21:35 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-07-06 05:34:34 +0800
commitfd6445439e671d00cfa09362aee24135149ce392 (patch)
treec4774ae898b6bf5102bcd6b82b48b762d719af3c /packages/website/ts/utils
parent51fa8d3e24939cffc043bf97e478390df129ca27 (diff)
downloaddexon-sol-tools-fd6445439e671d00cfa09362aee24135149ce392.tar
dexon-sol-tools-fd6445439e671d00cfa09362aee24135149ce392.tar.gz
dexon-sol-tools-fd6445439e671d00cfa09362aee24135149ce392.tar.bz2
dexon-sol-tools-fd6445439e671d00cfa09362aee24135149ce392.tar.lz
dexon-sol-tools-fd6445439e671d00cfa09362aee24135149ce392.tar.xz
dexon-sol-tools-fd6445439e671d00cfa09362aee24135149ce392.tar.zst
dexon-sol-tools-fd6445439e671d00cfa09362aee24135149ce392.zip
Implement landing page change in preperation for portal
Diffstat (limited to 'packages/website/ts/utils')
-rw-r--r--packages/website/ts/utils/translate.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/website/ts/utils/translate.ts b/packages/website/ts/utils/translate.ts
index 39924b6f7..1ee1a59c5 100644
--- a/packages/website/ts/utils/translate.ts
+++ b/packages/website/ts/utils/translate.ts
@@ -55,6 +55,19 @@ export class Translate {
}
public get(key: Key, decoration?: Deco): string {
let text = this._translation[key];
+ // if a translation does not exist for a certain language, fallback to english
+ // if it still doesn't exist in english, throw an error
+ if (_.isUndefined(text)) {
+ const englishTranslation: Translation = languageToTranslations[Language.English];
+ const englishText = englishTranslation[key];
+ if (!_.isUndefined(englishText)) {
+ text = englishText;
+ } else {
+ throw new Error(
+ `Translation key not available in ${this._selectedLanguage} or ${Language.English}: ${key}`,
+ );
+ }
+ }
if (!_.isUndefined(decoration) && !_.includes(languagesWithoutCaps, this._selectedLanguage)) {
switch (decoration) {
case Deco.Cap: