Web: Added convertLanguage for compatibility

This commit is contained in:
Alexey Safronov 2021-12-23 14:01:08 +03:00
parent 31f03a430b
commit 440811e931
3 changed files with 22 additions and 4 deletions

View File

@ -305,3 +305,20 @@ export function isRetina() {
if (window.matchMedia && window.matchMedia(mediaQuery).matches) return true;
return false;
}
export function convertLanguage(key) {
switch (key) {
case "en-US":
return "en";
case "ru-RU":
return "ru";
case "de-DE":
return "de";
case "it-IT":
return "it";
case "fr-FR":
return "fr";
}
return key;
}

View File

@ -13,7 +13,7 @@ import { inject, observer } from "mobx-react";
import { showLoader, hideLoader } from "@appserver/common/utils";
import { withRouter } from "react-router";
import { AppServerConfig } from "@appserver/common/constants";
import { combineUrl } from "@appserver/common/utils";
import { combineUrl, convertLanguage } from "@appserver/common/utils";
import withCultureNames from "@appserver/common/hoc/withCultureNames";
import config from "../../../../../../package.json";
import NoUserSelect from "@appserver/components/utils/commonStyles";
@ -224,8 +224,8 @@ class ProfileInfo extends React.PureComponent {
} = profile;
const type = isVisitor ? guestCaption : userCaption;
let language = cultureName || currentCulture || culture;
language = language == "en-US" ? "en" : language;
const language = convertLanguage(cultureName || currentCulture || culture);
//const languages = this.getLanguages();
const selectedLanguage = cultureNames.find(
(item) => item.key === language

View File

@ -13,6 +13,7 @@ import { saveToSessionStorage, getFromSessionStorage } from "../../utils";
import { setDocumentTitle } from "../../../../../helpers/utils";
import { inject, observer } from "mobx-react";
import { LANGUAGE } from "@appserver/common/constants";
import { convertLanguage } from "@appserver/common/utils";
import withCultureNames from "@appserver/common/hoc/withCultureNames";
const mapTimezonesToArray = (timezones) => {
@ -69,7 +70,7 @@ class LanguageAndTimeZone extends React.Component {
const timezones = mapTimezonesToArray(rawTimezones);
const language = findSelectedItemByKey(
cultureNames,
portalLanguage || cultureNames[0]
convertLanguage(portalLanguage || cultureNames[0])
);
const timezone = findSelectedItemByKey(
timezones,