Merge pull request #13829 from yangfei4913438/yangfei/translate-user-list

Fixed the translation problem of zh-Hans on the user list page.
This commit is contained in:
Julie Plantey 2022-07-25 18:22:34 +02:00 committed by GitHub
commit b1ce10f7f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 13 deletions

View File

@ -63,7 +63,7 @@ const TableRows = ({
return ( return (
<Td key={key}> <Td key={key}>
{typeof cellFormatter === 'function' ? ( {typeof cellFormatter === 'function' ? (
cellFormatter(data, { key, name, ...rest }) cellFormatter(data, { key, name, formatMessage, ...rest })
) : ( ) : (
<Typography textColor="neutral800">{data[name] || '-'}</Typography> <Typography textColor="neutral800">{data[name] || '-'}</Typography>
)} )}

View File

@ -24,9 +24,18 @@ const tableHeaders = [
name: 'roles', name: 'roles',
metadatas: { label: 'Roles', sortable: false }, metadatas: { label: 'Roles', sortable: false },
/* eslint-disable react/prop-types */ /* eslint-disable react/prop-types */
cellFormatter: ({ roles }) => { cellFormatter: ({ roles }, { formatMessage }) => {
return ( return (
<Typography textColor="neutral800">{roles.map(role => role.name).join(',\n')}</Typography> <Typography textColor="neutral800">
{roles
.map(role =>
formatMessage({
id: `global.${role.code}`,
defaultMessage: role.name,
})
)
.join(',\n')}
</Typography>
); );
}, },
/* eslint-enable react/prop-types */ /* eslint-enable react/prop-types */
@ -41,11 +50,16 @@ const tableHeaders = [
name: 'isActive', name: 'isActive',
metadatas: { label: 'User status', sortable: false }, metadatas: { label: 'User status', sortable: false },
// eslint-disable-next-line react/prop-types // eslint-disable-next-line react/prop-types
cellFormatter: ({ isActive }) => { cellFormatter: ({ isActive }, { formatMessage }) => {
return ( return (
<Flex> <Flex>
<Status isActive={isActive} variant={isActive ? 'success' : 'danger'} /> <Status isActive={isActive} variant={isActive ? 'success' : 'danger'} />
<Typography textColor="neutral800">{isActive ? 'Active' : 'Inactive'}</Typography> <Typography textColor="neutral800">
{formatMessage({
id: isActive ? 'global.active' : 'global.inactive',
defaultMessage: isActive ? 'Active' : 'Inactive',
})}
</Typography>
</Flex> </Flex>
); );
}, },

View File

@ -73,7 +73,10 @@ const SelectRoles = ({ disabled, error, onChange, value }) => {
{(data || []).map(role => { {(data || []).map(role => {
return ( return (
<Option key={role.id} value={role.id}> <Option key={role.id} value={role.id}>
{role.name} {formatMessage({
id: `global.${role.code}`,
defaultMessage: role.name,
})}
</Option> </Option>
); );
})} })}

View File

@ -3,6 +3,7 @@
"Auth.components.Oops.text": "Your account has been suspended.", "Auth.components.Oops.text": "Your account has been suspended.",
"Auth.components.Oops.text.admin": "If this is a mistake, please contact your administrator.", "Auth.components.Oops.text.admin": "If this is a mistake, please contact your administrator.",
"Auth.components.Oops.title": "Oops...", "Auth.components.Oops.title": "Oops...",
"Auth.form.active.label": "Active",
"Auth.form.button.forgot-password": "Send Email", "Auth.form.button.forgot-password": "Send Email",
"Auth.form.button.go-home": "GO BACK HOME", "Auth.form.button.go-home": "GO BACK HOME",
"Auth.form.button.login": "Login", "Auth.form.button.login": "Login",
@ -686,6 +687,8 @@
"form.button.done": "Done", "form.button.done": "Done",
"global.search": "Search", "global.search": "Search",
"global.actions": "Actions", "global.actions": "Actions",
"global.active": "Active",
"global.inactive": "Inactive",
"global.back": "Back", "global.back": "Back",
"global.cancel": "Cancel", "global.cancel": "Cancel",
"global.change-password": "Change password", "global.change-password": "Change password",
@ -731,6 +734,15 @@
"global.select": "Select", "global.select": "Select",
"global.select-all-entries": "Select all entries", "global.select-all-entries": "Select all entries",
"global.settings": "Settings", "global.settings": "Settings",
"global.strapi-super-admin": "Super Admin",
"global.strapi-editor": "Editor",
"global.strapi-author": "Author",
"global.table.header.email": "Email",
"global.table.header.firstname": "Firstname",
"global.table.header.isActive": "User status",
"global.table.header.lastname": "Lastname",
"global.table.header.roles": "Roles",
"global.table.header.username": "Username",
"global.type": "Type", "global.type": "Type",
"global.users": "Users", "global.users": "Users",
"notification.contentType.relations.conflict": "Content type has conflicting relations", "notification.contentType.relations.conflict": "Content type has conflicting relations",

View File

@ -3,6 +3,7 @@
"Auth.components.Oops.text": "你的帐号已经被停用。", "Auth.components.Oops.text": "你的帐号已经被停用。",
"Auth.components.Oops.text.admin": "如果这是个错误,请联系你的管理员。", "Auth.components.Oops.text.admin": "如果这是个错误,请联系你的管理员。",
"Auth.components.Oops.title": "哎呀...", "Auth.components.Oops.title": "哎呀...",
"Auth.form.active.label": "激活",
"Auth.form.button.forgot-password": "发送电子邮件", "Auth.form.button.forgot-password": "发送电子邮件",
"Auth.form.button.go-home": "回到首页", "Auth.form.button.go-home": "回到首页",
"Auth.form.button.login": "登录", "Auth.form.button.login": "登录",
@ -382,7 +383,7 @@
"components.ProductionBlocker.description": "为了安全起见,我们必须在其他环境下禁用这个插件。", "components.ProductionBlocker.description": "为了安全起见,我们必须在其他环境下禁用这个插件。",
"components.ProductionBlocker.header": "这个插件只在开发环境中可用。", "components.ProductionBlocker.header": "这个插件只在开发环境中可用。",
"components.Search.placeholder": "搜索...", "components.Search.placeholder": "搜索...",
"components.TableHeader.sort": "按 {label} 排序", "components.TableHeader.sort": "按{label}排序",
"components.Wysiwyg.ToggleMode.markdown-mode": "Markdown 模式", "components.Wysiwyg.ToggleMode.markdown-mode": "Markdown 模式",
"components.Wysiwyg.ToggleMode.preview-mode": "预览模式", "components.Wysiwyg.ToggleMode.preview-mode": "预览模式",
"components.Wysiwyg.collapse": "收起", "components.Wysiwyg.collapse": "收起",
@ -613,6 +614,8 @@
"content-type-builder.plugin.name": "模型构建器", "content-type-builder.plugin.name": "模型构建器",
"form.button.done": "完成", "form.button.done": "完成",
"global.search": "搜索", "global.search": "搜索",
"global.active": "已激活",
"global.inactive": "未激活",
"global.back": "返回", "global.back": "返回",
"global.cancel": "取消", "global.cancel": "取消",
"global.change-password": "修改密码", "global.change-password": "修改密码",
@ -650,6 +653,15 @@
"global.roles": "角色列表", "global.roles": "角色列表",
"global.save": "保存", "global.save": "保存",
"global.settings": "设置", "global.settings": "设置",
"global.strapi-super-admin": "超级管理员",
"global.strapi-editor": "编辑",
"global.strapi-author": "作者",
"global.table.header.email": "电子邮件",
"global.table.header.firstname": "名字",
"global.table.header.isActive": "是否激活",
"global.table.header.lastname": "姓氏",
"global.table.header.roles": "用户角色",
"global.table.header.username": "用户名",
"global.users": "用户列表", "global.users": "用户列表",
"global.type": "类型", "global.type": "类型",
"notification.contentType.relations.conflict": "内容类型有关联冲突", "notification.contentType.relations.conflict": "内容类型有关联冲突",

View File

@ -44,11 +44,16 @@ const TableHead = ({
{headers.map(({ name, metadatas: { sortable: isSortable, label } }) => { {headers.map(({ name, metadatas: { sortable: isSortable, label } }) => {
const isSorted = sortBy === name; const isSorted = sortBy === name;
const isUp = sortOrder === 'ASC'; const isUp = sortOrder === 'ASC';
const intlLabel = formatMessage({
id: `global.table.header.${name}`,
defaultMessage: label,
});
const sortLabel = formatMessage( const sortLabel = formatMessage(
{ id: 'components.TableHeader.sort', defaultMessage: 'Sort on {label}' }, { id: 'components.TableHeader.sort', defaultMessage: 'Sort on {label}' },
{ label } { label: intlLabel }
); );
const intlLabel = formatMessage({ id: label || name, defaultMessage: label || name });
const handleClickSort = (shouldAllowClick = true) => { const handleClickSort = (shouldAllowClick = true) => {
if (isSortable && shouldAllowClick) { if (isSortable && shouldAllowClick) {
@ -65,15 +70,13 @@ const TableHead = ({
<Th <Th
key={name} key={name}
action={ action={
isSorted ? ( isSorted && (
<IconButton <IconButton
label={sortLabel} label={sortLabel}
onClick={handleClickSort} onClick={handleClickSort}
icon={isSorted ? <SortIcon isUp={isUp} /> : undefined} icon={isSorted && <SortIcon isUp={isUp} />}
noBorder noBorder
/> />
) : (
undefined
) )
} }
> >