Update IntlProvider.tsx

This commit is contained in:
Abdulaziz 2022-06-09 21:07:00 +03:00 committed by GitHub
parent 3b420b7f4a
commit 337b9c65ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ import { createIntl, createIntlCache } from "react-intl";
import langDe from "./lang/de.json";
import langEn from "./lang/en.json";
import langFa from "./lang/fa.json";
import langAR from "./lang/ar.json";
import langList from "./lang/lang-list.json";
// first item of each array should be the language code,
@ -12,6 +13,7 @@ const localeOptions = [
["en", "en-US"],
["de", "de-DE"],
["fa", "fa-IR"],
["ar", "ar-SA"],
];
const loadMessages = (locale?: string): typeof langList & typeof langEn => {
@ -21,6 +23,8 @@ const loadMessages = (locale?: string): typeof langList & typeof langEn => {
return Object.assign({}, langList, langEn, langDe);
case "fa":
return Object.assign({}, langList, langEn, langFa);
case "ar":
return Object.assign({}, langList, langEn, langAR);
default:
return Object.assign({}, langList, langEn);
}
@ -34,6 +38,9 @@ const getFlagCodeForLocale = (locale?: string) => {
case "fa-IR":
case "fa":
return "IR";
case "ar-SA":
case "ar":
return "AR";
default:
return "US";
}