Closed zhengAnBin closed 3 years ago
你的切换代码是怎么写的?
你的切换代码是怎么写的?
这里的切换是一个 SelectLang 组件引入,然后没其他的啦
然后locales 里面的en-Us 我加上了这个 'menu.目标看板': 'origin', 'menu.计划': 'plan', 'menu.PDPs': 'PDPs', 'menu.大盘': 'market',
zh-CN里面我加上了 'menu.目标看板': '目标看板', 'menu.计划': '计划', 'menu.PDPs': '职业规划', 'menu.大盘': '大盘',
难道是 “menu.计划” 这个东西不能写中文? 还有我的默认配置是中文,但是显示出来的却是英文,这是因为什么原因造成的呢
emmm, 他会用你的name,你看一下控制台输出了什么的。
'menu.计划': '计划',
需要在 config.js 中配置 name :"计划"
emmm, 他会用你的name,你看一下控制台输出了什么的。
'menu.计划': '计划',
需要在 config.js 中配置name :"计划"
我config中有设置 name: '计划',其他对应的都有设置,但就是没作用,依然还是无法正常切换语言,而且各个浏览器表现不一样
你的控制台看一下,应该输出了一堆warning,告诉你该用什么key
我控制台唯一的一个报错是在 chomre 下 Warning: The current popular language does not exist, please check the locales folder! 看起来像是 locales 文件下没有 en 对应的语言包,因为 getLocale 打印出来的是 en 而不是 en-US 而其他浏览器不会报错 因为在其他浏览器下使用 getLocale 打印出来的是 en-US 所有浏览器的共同点就是切换不了语言
这个是语言不存在 你清空下缓存 然后在看
昨晚我连电脑都换了一个 现在倒是不会报错了,各个浏览器显示的也是我默认的设置的中文 但那个切换的语言的问题还在,切换完还是跳会默认的中文 我准备 clone 一个新的 antd desgin pro 将代码拷贝过去算了
🧐 问题描述
国际化出了问题了
我默认配置了中文
locale: { default: 'zh-CN', antd: true, baseNavigator: true, }
但显示效果却跟我所配置的不一样
我使用 getLocale 查看语言信息
1,在chomre 下打印 en 但界面上显示出来的却是中文 2,在Edge下打印 en-US 显示出来的是英文 3,在 firefox 下打印 en-US 显示出来的是英文
清除缓存,重启项目,没有用
而且当我切换语言时,无论切换中文还是英文,表现出来的效果都跟一开始一样,就是没有被切换,浏览器没有如何报错信息
我想我在改我的项目时,修改了里面的ant desgin pro中哪些自带的代码导致 但我已经忘记我修改了哪些代码
package.json
{ "name": "ant-design-pro", "version": "5.0.0-beta.2", "private": true, "description": "An out-of-box UI solution for enterprise applications", "scripts": { "analyze": "cross-env ANALYZE=1 umi build", "build": "umi build", "deploy": "npm run site && npm run gh-pages", "dev": "npm run start:dev", "gh-pages": "gh-pages -d dist", "i18n-remove": "pro i18n-remove --locale=zh-CN --write", "postinstall": "umi g tmp", "lint": "umi g tmp && npm run lint:js && npm run lint:style && npm run lint:prettier", "lint-staged": "lint-staged", "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ", "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src && npm run lint:style", "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx --format=pretty ./src", "lint:prettier": "prettier --check \"src//*\" --end-of-line auto", "lint:style": "stylelint --fix \"src/*/.less\" --syntax less", "precommit": "lint-staged", "prettier": "prettier -c --write \"src//*\"", "start": "umi dev", "start:dev": "cross-env REACT_APP_ENV=dev MOCK=none umi dev", "start:no-mock": "cross-env MOCK=none umi dev", "start:no-ui": "cross-env UMI_UI=none umi dev", "start:pre": "cross-env REACT_APP_ENV=pre umi dev", "start:test": "cross-env REACT_APP_ENV=test MOCK=none umi dev", "pretest": "node ./tests/beforeTest", "test": "umi test", "test:all": "node ./tests/run-tests.js", "test:component": "umi test ./src/components", "tsc": "tsc --noEmit" }, "lint-staged": { "/*.less": "stylelint --syntax less", "*/.{js,jsx,ts,tsx}": "npm run lint-staged:js", "/*.{js,jsx,tsx,ts,less,md,json}": [ "prettier --write" ] }, "browserslist": [ "> 1%", "last 2 versions", "not ie <= 10" ], "dependencies": { "@ant-design/icons": "^4.0.0", "@ant-design/pro-descriptions": "^1.0.19", "@ant-design/pro-form": "^1.3.0", "@ant-design/pro-layout": "^6.5.0", "@ant-design/pro-table": "^2.9.16", "@antv/g6": "^4.0.3", "@umijs/route-utils": "^1.0.33", "antd": "^4.9.2", "braft-editor": "^2.3.9", "classnames": "^2.2.6", "lodash": "^4.17.11", "moment": "^2.25.3", "omit.js": "^2.0.2", "qs": "^6.9.0", "react": "^17.0.0", "react-dev-inspector": "^1.1.1", "react-dom": "^17.0.0", "react-helmet-async": "^1.0.4", "umi": "^3.3.3", "umi-request": "^1.0.8", "use-merge-value": "^1.0.1" }, "devDependencies": { "@ant-design/pro-cli": "^2.0.2", "@types/classnames": "^2.2.7", "@types/express": "^4.17.0", "@types/history": "^4.7.2", "@types/jest": "^26.0.0", "@types/lodash": "^4.14.144", "@types/qs": "^6.5.3", "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "@types/react-helmet": "^6.1.0", "@umijs/fabric": "^2.4.0", "@umijs/plugin-blocks": "^2.0.5", "@umijs/plugin-esbuild": "^1.0.1", "@umijs/preset-ant-design-pro": "^1.2.0", "@umijs/preset-dumi": "^1.1.0-rc.6", "@umijs/preset-react": "^1.7.4", "@umijs/yorkie": "^2.0.3", "carlo": "^0.9.46", "cross-env": "^7.0.0", "cross-port-killer": "^1.1.1", "detect-installer": "^1.0.1", "enzyme": "^3.11.0", "eslint": "^7.1.0", "express": "^4.17.1", "gh-pages": "^3.0.0", "jsdom-global": "^3.0.2", "lint-staged": "^10.0.0", "mockjs": "^1.0.1-beta3", "prettier": "^2.0.1", "pro-download": "1.0.1", "puppeteer-core": "^5.0.0", "stylelint": "^13.0.0", "typescript": "^4.0.3" }, "engines": { "node": ">=10.0.0" } }