From b850cfe0e6fe1b45511c3307acd444bd32f68096 Mon Sep 17 00:00:00 2001 From: lleohao <12764126+lleohao@users.noreply.github.com> Date: Tue, 3 Sep 2024 02:09:17 +0000 Subject: [PATCH] feat: complete space translation --- apps/client/public/locales/en/settings.json | 35 +-------------- apps/client/public/locales/en/space.json | 45 +++++++++++++++++++ .../client/public/locales/en/translation.json | 5 +-- apps/client/public/locales/en/workspace.json | 1 + apps/client/public/locales/zh/settings.json | 35 +-------------- apps/client/public/locales/zh/space.json | 45 +++++++++++++++++++ .../client/public/locales/zh/translation.json | 5 +-- apps/client/public/locales/zh/workspace.json | 3 ++ .../components/add-space-members-modal.tsx | 4 +- .../space/components/create-space-form.tsx | 4 +- .../space/components/create-space-modal.tsx | 4 +- .../space/components/edit-space-form.tsx | 4 +- .../space/components/multi-member-select.tsx | 4 +- .../space/components/settings-modal.tsx | 4 +- .../components/sidebar/space-sidebar.tsx | 29 +++++++----- .../space/components/space-details.tsx | 4 +- .../features/space/components/space-grid.tsx | 3 +- .../space/components/space-home-tabs.tsx | 4 +- .../features/space/components/space-list.tsx | 4 +- .../space/components/space-members.tsx | 4 +- 20 files changed, 127 insertions(+), 119 deletions(-) create mode 100644 apps/client/public/locales/en/space.json create mode 100644 apps/client/public/locales/en/workspace.json create mode 100644 apps/client/public/locales/zh/space.json create mode 100644 apps/client/public/locales/zh/workspace.json diff --git a/apps/client/public/locales/en/settings.json b/apps/client/public/locales/en/settings.json index 02458dbd..1d56278d 100644 --- a/apps/client/public/locales/en/settings.json +++ b/apps/client/public/locales/en/settings.json @@ -103,39 +103,6 @@ "Search for groups": "Search for groups", "No group found": "No group found" }, - "space": { - "Spaces": "Spaces", - "Create space": "Create space", - "Space": "Space", - "Members": "Members", - "Settings": "Settings", - "Details": "Details", - "Name": "Name", - "e.g Sales": "e.g Sales", - "Slug": "Slug", - "Description": "Description", - "e.g Space for sales team to collaborate": "e.g Space for sales team to collaborate", - "Save": "Save", - "Space name": "Space name", - "e.g Product Team": "e.g Product Team", - "Space slug": "Space slug", - "e.g product": "e.g product", - "Space description": "Space description", - "e.g Space for product team": "e.g Space for product team", - "Create": "Create", - "addSpaceMembers": "addSpaceMembers", - "add": "add", - "selectRole": "selectRole", - "Remove space member": "Remove space member", - "Are you sure you want to remove this user from the space? The user will lose all access to this space.": "Are you sure you want to remove this user from the space? The user will lose all access to this space.", - "Remove": "Remove", - "Cancel": "Cancel", - "Member": "Member", - "Role": "Role", - "Failed to load page. An error occurred.": "Failed to load page. An error occurred.", - "Add members": "Add members", - "Search for users and groups": "Search for users and groups", - "No user found": "No user found" - } + "space": {} } } diff --git a/apps/client/public/locales/en/space.json b/apps/client/public/locales/en/space.json new file mode 100644 index 00000000..8f98592c --- /dev/null +++ b/apps/client/public/locales/en/space.json @@ -0,0 +1,45 @@ +{ + "Overview": "Overview", + "Search": "Search", + "Space settings": "Space settings", + "New page": "New page", + "Pages": "Pages", + "Create page": "Create page", + "Import pages & space settings": "Import pages & space settings", + "Space menu": "Space menu", + "Import pages": "Import pages", + "Spaces": "Spaces", + "Create space": "Create space", + "Space": "Space", + "Members": "Members", + "Settings": "Settings", + "Details": "Details", + "Name": "Name", + "e.g Sales": "e.g Sales", + "Slug": "Slug", + "Description": "Description", + "e.g Space for sales team to collaborate": "e.g Space for sales team to collaborate", + "Save": "Save", + "Space name": "Space name", + "e.g Product Team": "e.g Product Team", + "Space slug": "Space slug", + "e.g product": "e.g product", + "Space description": "Space description", + "e.g Space for product team": "e.g Space for product team", + "Create": "Create", + "addSpaceMembers": "addSpaceMembers", + "add": "add", + "selectRole": "selectRole", + "Remove space member": "Remove space member", + "Are you sure you want to remove this user from the space? The user will lose all access to this space.": "Are you sure you want to remove this user from the space? The user will lose all access to this space.", + "Remove": "Remove", + "Cancel": "Cancel", + "Member": "Member", + "Role": "Role", + "Failed to load page. An error occurred.": "Failed to load page. An error occurred.", + "Add members": "Add members", + "Search for users and groups": "Search for users and groups", + "No user found": "No user found", + "Spaces you belong to": "Spaces you belong to", + "Recently updated": "Recently updated" +} diff --git a/apps/client/public/locales/en/translation.json b/apps/client/public/locales/en/translation.json index 548f3541..554a9e31 100644 --- a/apps/client/public/locales/en/translation.json +++ b/apps/client/public/locales/en/translation.json @@ -39,10 +39,7 @@ "home": { "Recently updated": "Recently updated" }, - "space": { - "Spaces you belong to": "Spaces you belong to", - "Recently updated": "Recently updated" - }, + "space": {}, "page": { "Error fetching page data.": "Error fetching page data.", "untitled": "untitled", diff --git a/apps/client/public/locales/en/workspace.json b/apps/client/public/locales/en/workspace.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/apps/client/public/locales/en/workspace.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/apps/client/public/locales/zh/settings.json b/apps/client/public/locales/zh/settings.json index 6616fd70..c4125909 100644 --- a/apps/client/public/locales/zh/settings.json +++ b/apps/client/public/locales/zh/settings.json @@ -103,39 +103,6 @@ "Search for groups": "搜索群组", "No group found": "未找到群组" }, - "space": { - "Spaces": "空间", - "Create space": "创建空间", - "Space": "空间", - "Members": "成员", - "Settings": "设置", - "Details": "详情", - "Name": "名称", - "e.g Sales": "例如:销售", - "Slug": "短链接", - "Description": "描述", - "e.g Space for sales team to collaborate": "例如:销售团队协作的空间", - "Save": "保存", - "Space name": "空间名称", - "e.g Product Team": "例如:产品团队", - "Space slug": "空间短链接", - "e.g product": "例如:product", - "Space description": "空间描述", - "e.g Space for product team": "例如:产品团队的空间", - "Create": "创建", - "addSpaceMembers": "添加空间成员", - "add": "添加", - "selectRole": "选择角色", - "Remove space member": "移除空间成员", - "Are you sure you want to remove this user from the space? The user will lose all access to this space.": "您确定要从空间中移除这个用户吗?该用户将失去对这个空间的所有访问权限。", - "Remove": "移除", - "Cancel": "取消", - "Member": "成员", - "Role": "角色", - "Failed to load page. An error occurred.": "页面加载失败。发生了一个错误。", - "Add members": "添加成员", - "Search for users and groups": "搜索用户和群组", - "No user found": "未找到用户" - } + "space": {} } } diff --git a/apps/client/public/locales/zh/space.json b/apps/client/public/locales/zh/space.json new file mode 100644 index 00000000..fe7f7744 --- /dev/null +++ b/apps/client/public/locales/zh/space.json @@ -0,0 +1,45 @@ +{ + "Overview": "概览", + "Search": "搜索", + "Space settings": "空间设置", + "New page": "新建页面", + "Pages": "页面", + "Create page": "创建页面", + "Import pages & space settings": "导入页面和空间设置", + "Space menu": "空间菜单", + "Import pages": "导入页面", + "Spaces": "空间", + "Create space": "创建空间", + "Space": "空间", + "Members": "成员", + "Settings": "设置", + "Details": "详情", + "Name": "名称", + "e.g Sales": "例如:销售", + "Slug": "短链接", + "Description": "描述", + "e.g Space for sales team to collaborate": "例如:销售团队协作的空间", + "Save": "保存", + "Space name": "空间名称", + "e.g Product Team": "例如:产品团队", + "Space slug": "空间短链接", + "e.g product": "例如:product", + "Space description": "空间描述", + "e.g Space for product team": "例如:产品团队的空间", + "Create": "创建", + "addSpaceMembers": "添加空间成员", + "add": "添加", + "selectRole": "选择角色", + "Remove space member": "移除空间成员", + "Are you sure you want to remove this user from the space? The user will lose all access to this space.": "您确定要从空间中移除这个用户吗?该用户将失去对这个空间的所有访问权限。", + "Remove": "移除", + "Cancel": "取消", + "Member": "成员", + "Role": "角色", + "Failed to load page. An error occurred.": "页面加载失败。发生了一个错误。", + "Add members": "添加成员", + "Search for users and groups": "搜索用户和群组", + "No user found": "未找到用户", + "Spaces you belong to": "您所属的空间", + "Recently updated": "最近更新" +} diff --git a/apps/client/public/locales/zh/translation.json b/apps/client/public/locales/zh/translation.json index 9f2d5d22..a6854102 100644 --- a/apps/client/public/locales/zh/translation.json +++ b/apps/client/public/locales/zh/translation.json @@ -39,10 +39,7 @@ "home": { "Recently updated": "最近更新" }, - "space": { - "Spaces you belong to": "您所属的空间", - "Recently updated": "最近更新" - }, + "space": {}, "page": { "Error fetching page data.": "获取页面数据时出错。", "untitled": "无标题", diff --git a/apps/client/public/locales/zh/workspace.json b/apps/client/public/locales/zh/workspace.json new file mode 100644 index 00000000..5a6f8453 --- /dev/null +++ b/apps/client/public/locales/zh/workspace.json @@ -0,0 +1,3 @@ +{ + "space": {} +} diff --git a/apps/client/src/features/space/components/add-space-members-modal.tsx b/apps/client/src/features/space/components/add-space-members-modal.tsx index e7732bcc..427a45bb 100644 --- a/apps/client/src/features/space/components/add-space-members-modal.tsx +++ b/apps/client/src/features/space/components/add-space-members-modal.tsx @@ -13,9 +13,7 @@ interface AddSpaceMemberModalProps { export default function AddSpaceMembersModal({ spaceId, }: AddSpaceMemberModalProps) { - const { t } = useTranslation("settings", { - keyPrefix: "workspace.space", - }); + const { t } = useTranslation("space"); const [opened, { open, close }] = useDisclosure(false); const [memberIds, setMemberIds] = useState([]); const [role, setRole] = useState(SpaceRole.WRITER); diff --git a/apps/client/src/features/space/components/create-space-form.tsx b/apps/client/src/features/space/components/create-space-form.tsx index d07d3371..29dc0c2d 100644 --- a/apps/client/src/features/space/components/create-space-form.tsx +++ b/apps/client/src/features/space/components/create-space-form.tsx @@ -23,9 +23,7 @@ const formSchema = z.object({ type FormValues = z.infer; export function CreateSpaceForm() { - const { t } = useTranslation("settings", { - keyPrefix: "workspace.space", - }); + const { t } = useTranslation("space"); const createSpaceMutation = useCreateSpaceMutation(); const navigate = useNavigate(); diff --git a/apps/client/src/features/space/components/create-space-modal.tsx b/apps/client/src/features/space/components/create-space-modal.tsx index 0f75ba02..3557f522 100644 --- a/apps/client/src/features/space/components/create-space-modal.tsx +++ b/apps/client/src/features/space/components/create-space-modal.tsx @@ -4,9 +4,7 @@ import { CreateSpaceForm } from "@/features/space/components/create-space-form.t import { useTranslation } from "react-i18next"; export default function CreateSpaceModal() { - const { t } = useTranslation("settings", { - keyPrefix: "workspace.space", - }); + const { t } = useTranslation("space"); const [opened, { open, close }] = useDisclosure(false); return ( diff --git a/apps/client/src/features/space/components/edit-space-form.tsx b/apps/client/src/features/space/components/edit-space-form.tsx index 8a01c1dc..98579206 100644 --- a/apps/client/src/features/space/components/edit-space-form.tsx +++ b/apps/client/src/features/space/components/edit-space-form.tsx @@ -17,9 +17,7 @@ interface EditSpaceFormProps { readOnly?: boolean; } export function EditSpaceForm({ space, readOnly }: EditSpaceFormProps) { - const { t } = useTranslation("settings", { - keyPrefix: "workspace.space", - }); + const { t } = useTranslation("space"); const updateSpaceMutation = useUpdateSpaceMutation(); const form = useForm({ diff --git a/apps/client/src/features/space/components/multi-member-select.tsx b/apps/client/src/features/space/components/multi-member-select.tsx index 182b56d1..6c92fcd8 100644 --- a/apps/client/src/features/space/components/multi-member-select.tsx +++ b/apps/client/src/features/space/components/multi-member-select.tsx @@ -31,9 +31,7 @@ const renderMultiSelectOption: MultiSelectProps["renderOption"] = ({ ); export function MultiMemberSelect({ onChange }: MultiMemberSelectProps) { - const { t } = useTranslation("settings", { - keyPrefix: "workspace.space", - }); + const { t } = useTranslation("space"); const [searchValue, setSearchValue] = useState(""); const [debouncedQuery] = useDebouncedValue(searchValue, 500); const { data: suggestion, isLoading } = useSearchSuggestionsQuery({ diff --git a/apps/client/src/features/space/components/settings-modal.tsx b/apps/client/src/features/space/components/settings-modal.tsx index b5f418e8..4708b7fb 100644 --- a/apps/client/src/features/space/components/settings-modal.tsx +++ b/apps/client/src/features/space/components/settings-modal.tsx @@ -22,9 +22,7 @@ export default function SpaceSettingsModal({ opened, onClose, }: SpaceSettingsModalProps) { - const { t } = useTranslation("settings", { - keyPrefix: "workspace.space", - }); + const { t } = useTranslation("space"); const { data: space, isLoading } = useSpaceQuery(spaceId); const spaceRules = space?.membership?.permissions; diff --git a/apps/client/src/features/space/components/sidebar/space-sidebar.tsx b/apps/client/src/features/space/components/sidebar/space-sidebar.tsx index c56c93a7..17dcd44c 100644 --- a/apps/client/src/features/space/components/sidebar/space-sidebar.tsx +++ b/apps/client/src/features/space/components/sidebar/space-sidebar.tsx @@ -35,8 +35,10 @@ import { SpaceCaslSubject, } from "@/features/space/permissions/permissions.type.ts"; import PageImportModal from "@/features/page/components/page-import-modal.tsx"; +import { useTranslation } from "react-i18next"; export function SpaceSidebar() { + const { t } = useTranslation("space"); const [tree] = useAtom(treeApiAtom); const location = useLocation(); const [opened, { open: openSettings, close: closeSettings }] = @@ -86,7 +88,7 @@ export function SpaceSidebar() { className={classes.menuItemIcon} stroke={2} /> - Overview + {t("Overview")} @@ -97,7 +99,7 @@ export function SpaceSidebar() { className={classes.menuItemIcon} stroke={2} /> - Search + {t("Search")} @@ -108,7 +110,7 @@ export function SpaceSidebar() { className={classes.menuItemIcon} stroke={2} /> - Space settings + {t("Space settings")} @@ -126,7 +128,7 @@ export function SpaceSidebar() { className={classes.menuItemIcon} stroke={2} /> - New page + {t("New page")} )} @@ -136,7 +138,7 @@ export function SpaceSidebar() {
- Pages + {t("Pages")} {spaceAbility.can( @@ -146,12 +148,12 @@ export function SpaceSidebar() { - + @@ -188,6 +190,7 @@ interface SpaceMenuProps { onSpaceSettings: () => void; } function SpaceMenu({ spaceId, onSpaceSettings }: SpaceMenuProps) { + const { t } = useTranslation("space"); const [importOpened, { open: openImportModal, close: closeImportModal }] = useDisclosure(false); @@ -196,11 +199,15 @@ function SpaceMenu({ spaceId, onSpaceSettings }: SpaceMenuProps) { - + @@ -211,7 +218,7 @@ function SpaceMenu({ spaceId, onSpaceSettings }: SpaceMenuProps) { onClick={openImportModal} leftSection={} > - Import pages + {t("Import pages")} @@ -220,7 +227,7 @@ function SpaceMenu({ spaceId, onSpaceSettings }: SpaceMenuProps) { onClick={onSpaceSettings} leftSection={} > - Space settings + {t("Space settings")} diff --git a/apps/client/src/features/space/components/space-details.tsx b/apps/client/src/features/space/components/space-details.tsx index 26cb4230..7493f44f 100644 --- a/apps/client/src/features/space/components/space-details.tsx +++ b/apps/client/src/features/space/components/space-details.tsx @@ -9,9 +9,7 @@ interface SpaceDetailsProps { readOnly?: boolean; } export default function SpaceDetails({ spaceId, readOnly }: SpaceDetailsProps) { - const { t } = useTranslation("settings", { - keyPrefix: "workspace.space", - }); + const { t } = useTranslation("space"); const { data: space, isLoading } = useSpaceQuery(spaceId); return ( diff --git a/apps/client/src/features/space/components/space-grid.tsx b/apps/client/src/features/space/components/space-grid.tsx index 5d752a69..adae8c04 100644 --- a/apps/client/src/features/space/components/space-grid.tsx +++ b/apps/client/src/features/space/components/space-grid.tsx @@ -8,8 +8,7 @@ import { formatMemberCount } from "@/lib"; import { useTranslation } from "react-i18next"; export default function SpaceGrid() { - const { t } = useTranslation("translation", { keyPrefix: "space" }); - + const { t } = useTranslation("space"); const { data, isLoading } = useGetSpacesQuery(); const cards = data?.items.map((space, index) => ( diff --git a/apps/client/src/features/space/components/space-home-tabs.tsx b/apps/client/src/features/space/components/space-home-tabs.tsx index 4f650a45..8ecd1735 100644 --- a/apps/client/src/features/space/components/space-home-tabs.tsx +++ b/apps/client/src/features/space/components/space-home-tabs.tsx @@ -6,9 +6,7 @@ import { useGetSpaceBySlugQuery } from "@/features/space/queries/space-query.ts" import { useTranslation } from "react-i18next"; export default function SpaceHomeTabs() { - const { t } = useTranslation("translaction", { - keyPrefix: "workspace.space", - }); + const { t } = useTranslation("space"); const { spaceSlug } = useParams(); const { data: space } = useGetSpaceBySlugQuery(spaceSlug); diff --git a/apps/client/src/features/space/components/space-list.tsx b/apps/client/src/features/space/components/space-list.tsx index fe792823..6105f074 100644 --- a/apps/client/src/features/space/components/space-list.tsx +++ b/apps/client/src/features/space/components/space-list.tsx @@ -7,9 +7,7 @@ import { formatMemberCount } from "@/lib"; import { useTranslation } from "react-i18next"; export default function SpaceList() { - const { t } = useTranslation("settings", { - keyPrefix: "workspace.space", - }); + const { t } = useTranslation("space"); const { data, isLoading } = useGetSpacesQuery(); const [opened, { open, close }] = useDisclosure(false); const [selectedSpaceId, setSelectedSpaceId] = useState(null); diff --git a/apps/client/src/features/space/components/space-members.tsx b/apps/client/src/features/space/components/space-members.tsx index 99027711..fcfba14f 100644 --- a/apps/client/src/features/space/components/space-members.tsx +++ b/apps/client/src/features/space/components/space-members.tsx @@ -27,9 +27,7 @@ export default function SpaceMembersList({ spaceId, readOnly, }: SpaceMembersProps) { - const { t } = useTranslation("settings", { - keyPrefix: "workspace.space", - }); + const { t } = useTranslation("space"); const { data, isLoading } = useSpaceMembersQuery(spaceId); const removeSpaceMember = useRemoveSpaceMemberMutation(); const changeSpaceMemberRoleMutation = useChangeSpaceMemberRoleMutation();