chore dep: upgrade to lingui v4

This commit is contained in:
baorong
2026-02-13 17:39:53 +08:00
parent 67fc31a008
commit 152556d582
7 changed files with 203 additions and 22 deletions
+21
View File
@@ -0,0 +1,21 @@
import { formatter } from "@lingui/format-json"
export default {
fallbackLocales: {
default: "en",
},
sourceLocale: "en",
locales: ["en", "zh", "pt-br"],
catalogs: [
{
path: "src/locales/{locale}/messages",
include: [
"src/pages",
"src/layouts",
"src/components",
"src/layouts",
],
},
],
format: formatter({ style: "minimal" }),
}
+11 -12
View File
@@ -5,7 +5,7 @@
"description": "An admin dashboard application demo built upon Ant Design and UmiJS",
"dependencies": {
"@ant-design/icons": "^4.8.3",
"@lingui/react": "^3.17.2",
"@lingui/react": "^4.14.1",
"antd": "^5.16.1",
"axios": "^0.21.4",
"classnames": "^2.5.1",
@@ -41,10 +41,12 @@
},
"devDependencies": {
"@ant-design/compatible": "^5.1.2",
"@babel/core": "^7.29.0",
"@babel/preset-react": "^7.24.1",
"@lingui/cli": "^3.17.2",
"@lingui/core": "^4.8.0",
"@lingui/macro": "^3.17.2",
"@lingui/cli": "^4.14.1",
"@lingui/core": "^4.14.1",
"@lingui/format-json": "^5.9.1",
"@lingui/macro": "^4.14.1",
"@umijs/preset-react": "^1.8.32",
"babel-eslint": "^10.1.0",
"babel-plugin-dev-expression": "^0.2.3",
@@ -65,12 +67,16 @@
"mockjs": "^1.1.0",
"module": "^1.2.5",
"prettier": "^2.8.8",
"puppeteer": "^24.37.2",
"stylelint": "^13.13.1",
"stylelint-config-prettier": "^8.0.2",
"stylelint-config-standard": "^21.0.0",
"typescript": "^4.9.5",
"umi": "^3.5.41"
},
"overrides": {
"@babel/core": "^7.29.0"
},
"engines": {
"node": ">= 10.0.0"
},
@@ -106,14 +112,7 @@
"src/layouts"
]
}
],
"format": "minimal",
"extractBabelOptions": {
"presets": [
"@umijs/babel-preset-umi",
"@babel/preset-react"
]
}
]
},
"scripts": {
"analyze": "cross-env ANALYZE=1 umi build",
+4 -2
View File
@@ -1,10 +1,12 @@
import puppeteer from 'puppeteer'
const runE2E = process.env.RUN_E2E === '1'
const d = runE2E ? describe : describe.skip
describe('Login', () => {
d('Login', () => {
let browser
let page
beforeAll(async () => {
const puppeteer = require('puppeteer')
browser = await puppeteer.launch({ args: ['--no-sandbox'] })
})
+54 -2
View File
@@ -1,4 +1,5 @@
{
"Password": "Password",
"/dashboard": "/dashboard",
"Add Param": "Add Param",
"Address": "Address",
@@ -26,7 +27,6 @@
"Not Found": "Not Found",
"Operation": "Operation",
"Params": "Params",
"Password": "Password",
"Phone": "Phone",
"Pick an address": "Pick an address",
"Please pick an address": "Please pick an address",
@@ -50,5 +50,57 @@
"Username": "Username",
"Views": "Views",
"Visibility": "Visibility",
"You have viewed all notifications.": "You have viewed all notifications."
"You have viewed all notifications.": "You have viewed all notifications.",
"XxmuIa": "/dashboard",
"Bn3tSA": "Add Param",
"Du6bPw": "Address",
"RCU5PY": "Age",
"JOrM7W": "Are you sure delete this record?",
"VbeIOx": "Author",
"kfcRb0": "Avatar",
"NUrY9o": "Categories",
"uFxfjI": "Clear notifications",
"VbyRUy": "Comments",
"hYgDIe": "Create",
"Jd2r4y": "Create User",
"rWPWqL": "CreateTime",
"pvnfJD": "Dark",
"cnGeoo": "Delete",
"O3oNi5": "Email",
"M9iqFS": "Female",
"5iyJje": "Gender",
"bVsnqU": "Hi,",
"hG89Ed": "Image",
"1njn7W": "Light",
"CvCWBI": "Male",
"6YtxFj": "Name",
"fnzSx+": "NickName",
"pAtylB": "Not Found",
"FZg3wM": "Operation",
"LnZ59a": "Params",
"8ZsakT": "Password",
"zmwvG2": "Phone",
"sK+agT": "Pick an address",
"f4wMI5": "Please pick an address",
"Ef7VI0": "Publised",
"iUSbjZ": "Publish Date",
"OfhWJH": "Reset",
"A1taO8": "Search",
"BVgBUp": "Search Name",
"JlFcis": "Send",
"5lWFkC": "Sign in",
"fcWrnU": "Sign out",
"u/4llg": "Switch Theme",
"OYHzN1": "Tags",
"GqIw2D": "The input is not valid E-mail!",
"y4Rltr": "The input is not valid phone!",
"MHrjPM": "Title",
"EPhORN": "Total {total} Items",
"ejZKhw": "Unpublished",
"EkH9pt": "Update",
"99qsr/": "Update User",
"7sNhEz": "Username",
"1I6UoR": "Views",
"2q/Q7x": "Visibility",
"I4ObGc": "You have viewed all notifications."
}
+54 -2
View File
@@ -1,4 +1,5 @@
{
"Password": "Senha",
"/dashboard": "/dashboard",
"Add Param": "Add Parametro",
"Address": "Endereço",
@@ -26,7 +27,6 @@
"Not Found": "Não Encontrado",
"Operation": "Operation",
"Params": "Parametros",
"Password": "Senha",
"Phone": "Fone",
"Pick an address": "Escolha um endereço",
"Please pick an address": "Por favor, escolha um endereço",
@@ -50,5 +50,57 @@
"Username": "Usuário",
"Views": "visualizações",
"Visibility": "Visibilidade",
"You have viewed all notifications.": "Você visualizou todas as notificações."
"You have viewed all notifications.": "Você visualizou todas as notificações.",
"XxmuIa": "",
"Bn3tSA": "",
"Du6bPw": "",
"RCU5PY": "",
"JOrM7W": "",
"VbeIOx": "",
"kfcRb0": "",
"NUrY9o": "",
"uFxfjI": "",
"VbyRUy": "",
"hYgDIe": "",
"Jd2r4y": "",
"rWPWqL": "",
"pvnfJD": "",
"cnGeoo": "",
"O3oNi5": "",
"M9iqFS": "",
"5iyJje": "",
"bVsnqU": "",
"hG89Ed": "",
"1njn7W": "",
"CvCWBI": "",
"6YtxFj": "",
"fnzSx+": "",
"pAtylB": "",
"FZg3wM": "",
"LnZ59a": "",
"8ZsakT": "",
"zmwvG2": "",
"sK+agT": "",
"f4wMI5": "",
"Ef7VI0": "",
"iUSbjZ": "",
"OfhWJH": "",
"A1taO8": "",
"BVgBUp": "",
"JlFcis": "",
"5lWFkC": "",
"fcWrnU": "",
"u/4llg": "",
"OYHzN1": "",
"GqIw2D": "",
"y4Rltr": "",
"MHrjPM": "",
"EPhORN": "",
"ejZKhw": "",
"EkH9pt": "",
"99qsr/": "",
"7sNhEz": "",
"1I6UoR": "",
"2q/Q7x": "",
"I4ObGc": ""
}
+54 -2
View File
@@ -1,4 +1,5 @@
{
"Password": "密码",
"/dashboard": "/zh/dashboard",
"Add Param": "添加参数",
"Address": "地址",
@@ -26,7 +27,6 @@
"Not Found": "未找到",
"Operation": "操作",
"Params": "参数",
"Password": "密码",
"Phone": "电话",
"Pick an address": "选择地址",
"Please pick an address": "选择地址",
@@ -50,5 +50,57 @@
"Username": "用户名",
"Views": "浏览数",
"Visibility": "可见性",
"You have viewed all notifications.": "您已查看所有通知"
"You have viewed all notifications.": "您已查看所有通知",
"XxmuIa": "",
"Bn3tSA": "",
"Du6bPw": "",
"RCU5PY": "",
"JOrM7W": "",
"VbeIOx": "",
"kfcRb0": "",
"NUrY9o": "",
"uFxfjI": "",
"VbyRUy": "",
"hYgDIe": "",
"Jd2r4y": "",
"rWPWqL": "",
"pvnfJD": "",
"cnGeoo": "",
"O3oNi5": "",
"M9iqFS": "",
"5iyJje": "",
"bVsnqU": "",
"hG89Ed": "",
"1njn7W": "",
"CvCWBI": "",
"6YtxFj": "",
"fnzSx+": "",
"pAtylB": "",
"FZg3wM": "",
"LnZ59a": "",
"8ZsakT": "",
"zmwvG2": "",
"sK+agT": "",
"f4wMI5": "",
"Ef7VI0": "",
"iUSbjZ": "",
"OfhWJH": "",
"A1taO8": "",
"BVgBUp": "",
"JlFcis": "",
"5lWFkC": "",
"fcWrnU": "",
"u/4llg": "",
"OYHzN1": "",
"GqIw2D": "",
"y4Rltr": "",
"MHrjPM": "",
"EPhORN": "",
"ejZKhw": "",
"EkH9pt": "",
"99qsr/": "",
"7sNhEz": "",
"1I6UoR": "",
"2q/Q7x": "",
"I4ObGc": ""
}
+5 -2
View File
@@ -1,15 +1,18 @@
const { pathToRegexp } = require("path-to-regexp")
// strip known locale prefix (e.g. /zh, /en, /pt-br) before matching
const stripLocale = (p) => p.replace(/^\/(en|zh|pt-br)(\/|$)/, '/')
describe('test pathToRegexp', () => {
it('get right', () => {
expect(pathToRegexp('/user').exec('/zh/user')).toEqual(
expect(pathToRegexp('/user').exec(stripLocale('/zh/user'))).toEqual(
pathToRegexp('/user').exec('/user')
)
expect(pathToRegexp('/user').exec('/user')).toEqual(
pathToRegexp('/user').exec('/user')
)
expect(pathToRegexp('/user/:id').exec('/zh/user/1')).toEqual(
expect(pathToRegexp('/user/:id').exec(stripLocale('/zh/user/1'))).toEqual(
pathToRegexp('/user/:id').exec('/user/1')
)
expect(pathToRegexp('/user/:id').exec('/user/1')).toEqual(