import {LangId, MultiLangStringSet} from "../../definitions/auxillary/MultiLang"
import {store} from "../main"

const fallbackLangList: LangId[] = ["en", "fr", "zh_hans"]

export function text(
    s: MultiLangStringSet | string | null | undefined,
    lang: LangId = store.getState().ui.lang,
    fallbackLangs = fallbackLangList): string {
       if (s === null || typeof s === "undefined") {
           return ''
       }
       else if (typeof s === "string") {
           console.warn("Getting raw without multilang support:", s)
           return s
       }
       else {
           const translation = s[lang]
           if (translation) {
               return translation
           }
           else {
               for (let lang of fallbackLangs) {
                   let translation = s[lang]
                   if (translation) {
                       return translation
                   }
                }
           }
       }
       console.warn("Cannot convert to text: ", s)
       return ''
}

export default text

import {LangId, MultiLangStringSet} from "../../definitions/auxillary/MultiLang"
import {store} from "../main"

const fallbackLangList: LangId[] = ["en", "fr"]

export function text(
    s: MultiLangStringSet | string | null | undefined,
    lang: LangId = store.getState().ui.lang,
    fallbackLangs = fallbackLangList): string {
       if (s === null || typeof s === "undefined") {
           return ''
       }
       else if (typeof s === "string") {
           console.warn("Getting raw without multilang support:", s)
           return s
       }
       else {
           const translation = s[lang]
           if (translation) {
               return translation
           }
           else {
               for (let lang of fallbackLangs) {
                   let translation = s[lang]
                   if (translation) {
                       return translation
                   }
                }
           }
       }
       console.warn("Cannot convert to text: ", s)
       return ''
}

export default text

--- 
+++ 
@@ -1,7 +1,7 @@
 import {LangId, MultiLangStringSet} from "../../definitions/auxillary/MultiLang"
 import {store} from "../main"
 
-const fallbackLangList: LangId[] = ["en", "fr"]
+const fallbackLangList: LangId[] = ["en", "fr", "zh_hans"]
 
 export function text(
     s: MultiLangStringSet | string | null | undefined,
Add simplified Chinese to fallback list

Signed-off-by: Andy Shu <d9a5ae79e0620530e640970c782273ccd89702f2@gmail.com>
