mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 13:20:19 +08:00
Fix null bug in getCountryRegionData().
This commit is contained in:
@ -22,6 +22,7 @@ import copy from "copy-to-clipboard";
|
|||||||
import {authConfig} from "./auth/Auth";
|
import {authConfig} from "./auth/Auth";
|
||||||
import {Helmet} from "react-helmet";
|
import {Helmet} from "react-helmet";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import * as Conf from "./Conf";
|
||||||
|
|
||||||
export let ServerUrl = "";
|
export let ServerUrl = "";
|
||||||
|
|
||||||
@ -29,12 +30,17 @@ export let ServerUrl = "";
|
|||||||
export const StaticBaseUrl = "https://cdn.casbin.org";
|
export const StaticBaseUrl = "https://cdn.casbin.org";
|
||||||
|
|
||||||
// https://catamphetamine.gitlab.io/country-flag-icons/3x2/index.html
|
// https://catamphetamine.gitlab.io/country-flag-icons/3x2/index.html
|
||||||
export const CountryRegionData = getCountryRegionData()
|
export const CountryRegionData = getCountryRegionData();
|
||||||
|
|
||||||
export function getCountryRegionData() {
|
export function getCountryRegionData() {
|
||||||
|
let language = i18next.language;
|
||||||
|
if (language === null || language === "null") {
|
||||||
|
language = Conf.DefaultLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
var countries = require("i18n-iso-countries");
|
var countries = require("i18n-iso-countries");
|
||||||
countries.registerLocale(require("i18n-iso-countries/langs/" + i18next.language + ".json"));
|
countries.registerLocale(require("i18n-iso-countries/langs/" + language + ".json"));
|
||||||
var data = countries.getNames(i18next.language, {select: "official"});
|
var data = countries.getNames(language, {select: "official"});
|
||||||
var result = []
|
var result = []
|
||||||
for (var i in data)
|
for (var i in data)
|
||||||
result.push({code:i, name:data[i]})
|
result.push({code:i, name:data[i]})
|
||||||
|
Reference in New Issue
Block a user