Commit 6372d4f6 authored by 赵振东's avatar 赵振东

Merge branch 'v2-test' into 'v2-test'

fix: 国际化语言缓存问题 See merge request project/gaohuaxue-mobile-app!96 (cherry picked from commit 99437a44) 7a72e0ce fix: 国际化语言缓存问题
parent 08c4cb53
......@@ -19,8 +19,8 @@ import Icons from 'react-native-vector-icons/AntDesign';
import useLocale from '../../hooks/useLocale';
import { roleType } from '../../store/userStore/types';
import { getMemberMobileLoginReget } from '../../services/MemberV2Api';
import { getAsyncStorage } from '../../utils/storage';
import { USER_INFO } from '../../constants';
import { getAsyncStorage, setAsyncStorage } from '../../utils/storage';
import { LANGUAGE, USER_INFO } from '../../constants';
import i18n from '../../locales';
import { useCurrentRole } from '../../hooks/useCurrentRole';
......@@ -88,6 +88,18 @@ const Home: React.FC<HomeNavigationProp> = ({ navigation, route }) => {
];
useEffect(() => {
async function language() {
try {
let defaultlLanguage = await getAsyncStorage(LANGUAGE);
i18n.changeLanguage(defaultlLanguage?.code);
} catch {
setAsyncStorage(LANGUAGE, { code: 'zh-CN', label: '简体中文' });
}
}
language();
}, []);
useEffect(() => {
const getInfo = async () => {
try {
let _USER_INFO = userStore.userInfo;
......
......@@ -11,6 +11,7 @@ import { setAsyncStorage, getAsyncStorage } from '../../utils/storage';
import { LANGUAGE, lngs } from '../../constants/index';
import { useTranslation } from 'react-i18next';
import useLocale from '../../hooks/useLocale';
import Restart from 'react-native-restart';
const SelectLanguage = ({ navigation }: { route: any; navigation: any }) => {
const styles = useAppStyle(Styles);
......@@ -24,7 +25,9 @@ const SelectLanguage = ({ navigation }: { route: any; navigation: any }) => {
const comfirm = () => {
setAsyncStorage(LANGUAGE, lngs[currentIndex]);
i18n.changeLanguage(lngs[currentIndex].code);
navigation.replace('Home');
setTimeout(() => {
Restart.restart();
}, 1000);
};
const initLng = async () => {
......
......@@ -3010,16 +3010,11 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"
dayjs@^1.11.7:
dayjs@^1.11.7, dayjs@^1.8.15, dayjs@^1.8.16:
version "1.11.7"
resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.7.tgz#4b296922642f70999544d1144a2c25730fce63e2"
integrity sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ==
dayjs@^1.8.15, dayjs@^1.8.16:
version "1.11.7"
resolved "http://npm.shushangyun.com/dayjs/-/dayjs-1.11.7.tgz#4b296922642f70999544d1144a2c25730fce63e2"
integrity sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ==
debug@2.6.9, debug@^2.2.0, debug@^2.3.3:
version "2.6.9"
resolved "http://npm.shushangyun.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
......@@ -7197,6 +7192,11 @@ react-native-qrcode-svg@^6.1.2:
prop-types "^15.8.0"
qrcode "^1.5.1"
react-native-restart@^0.0.27:
version "0.0.27"
resolved "https://registry.npmmirror.com/react-native-restart/-/react-native-restart-0.0.27.tgz#43aa8210312c9dfa5ec7bd4b2f35238ad7972b19"
integrity sha512-8KScVICrXwcTSJ1rjWkqVTHyEKQIttm5AIMGSK1QG1+RS5owYlE4z/1DykOTdWfVl9l16FIk0w9Xzk9ZO6jxlA==
react-native-root-siblings@^4.0.0, react-native-root-siblings@^4.1.0, react-native-root-siblings@^4.1.1:
version "4.1.1"
resolved "http://npm.shushangyun.com/react-native-root-siblings/-/react-native-root-siblings-4.1.1.tgz#b7742db7634a87f507eb99a5fd699c4f10c46ab0"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment