aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils/translate.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-07-06 13:03:13 +0800
committerGitHub <noreply@github.com>2018-07-06 13:03:13 +0800
commitd975c0cef34d126ce30202610671a6f8dca6b6c0 (patch)
tree3c4ad472a6dc52b19eedd32ca06eddcb2464c883 /packages/website/ts/utils/translate.ts
parent51b86742d10a9e73fd017a0d052e0e423685eb69 (diff)
parent9f870b3d4ee1ce1ca4ddbac1efeabcb39cceebe8 (diff)
downloaddexon-sol-tools-d975c0cef34d126ce30202610671a6f8dca6b6c0.tar
dexon-sol-tools-d975c0cef34d126ce30202610671a6f8dca6b6c0.tar.gz
dexon-sol-tools-d975c0cef34d126ce30202610671a6f8dca6b6c0.tar.bz2
dexon-sol-tools-d975c0cef34d126ce30202610671a6f8dca6b6c0.tar.lz
dexon-sol-tools-d975c0cef34d126ce30202610671a6f8dca6b6c0.tar.xz
dexon-sol-tools-d975c0cef34d126ce30202610671a6f8dca6b6c0.tar.zst
dexon-sol-tools-d975c0cef34d126ce30202610671a6f8dca6b6c0.zip
Merge pull request #827 from 0xProject/feature/website/landing-page-cta
Landing page CTA for portal
Diffstat (limited to 'packages/website/ts/utils/translate.ts')
-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: