fix: save country code (#324)

Signed-off-by: “seriouszyx” <seriouszyx@foxmail.com>
This commit is contained in:
Yixiang Zhao
2021-11-11 14:38:35 +08:00
committed by GitHub
parent 37829062ad
commit cc933cf5f3
2 changed files with 8 additions and 1 deletions

View File

@ -47,7 +47,7 @@ class SelectRegionBox extends React.Component {
> >
{ {
Setting.CountryRegionData.map((item, index) => ( Setting.CountryRegionData.map((item, index) => (
<Option key={index} value={item.name} label={item.name} > <Option key={index} value={item.code} label={item.code} >
<img src={`${Setting.StaticBaseUrl}/flag-icons/${item.code}.svg`} alt={item.name} height={20} style={{marginRight: 10}}/> <img src={`${Setting.StaticBaseUrl}/flag-icons/${item.code}.svg`} alt={item.name} height={20} style={{marginRight: 10}}/>
{`${item.name} (${item.code})`} {`${item.name} (${item.code})`}
</Option> </Option>

View File

@ -116,6 +116,13 @@ class UserListPage extends React.Component {
} }
renderTable(users) { renderTable(users) {
// transfer country code to name based on selected language
var countries = require("i18n-iso-countries");
countries.registerLocale(require("i18n-iso-countries/langs/" + i18next.language + ".json"));
for (var index in users) {
users[index].region = countries.getName(users[index].region, i18next.language, {select: "official"})
}
const columns = [ const columns = [
{ {
title: i18next.t("general:Organization"), title: i18next.t("general:Organization"),