From cf75ef63f5742453ee28463a6d4c86e1d45e99a4 Mon Sep 17 00:00:00 2001 From: nighca Date: Wed, 30 Oct 2024 11:38:07 +0800 Subject: [PATCH] provide I18nT to simplify element translation --- spx-gui/.eslintrc.cjs | 3 +- .../project/ProjectPublishedModal.vue | 25 +++++------- spx-gui/src/pages/community/search.vue | 35 ++++++----------- spx-gui/src/utils/i18n/README.md | 19 ++++++++-- spx-gui/src/utils/i18n/index.ts | 38 ++++++++++++++++++- spx-gui/src/utils/utils.ts | 2 + 6 files changed, 76 insertions(+), 46 deletions(-) diff --git a/spx-gui/.eslintrc.cjs b/spx-gui/.eslintrc.cjs index 1ae5debb2..708c09728 100644 --- a/spx-gui/.eslintrc.cjs +++ b/spx-gui/.eslintrc.cjs @@ -28,7 +28,8 @@ module.exports = { // These rules will match components in both kebab-case and CamelCase 'router-view', 'router-link', - 'v-.*' // for Vue Konva components + 'v-.*', // for Vue Konva components + 'I18nT' ] } ], diff --git a/spx-gui/src/components/project/ProjectPublishedModal.vue b/spx-gui/src/components/project/ProjectPublishedModal.vue index 31131c839..0fd62d16a 100644 --- a/spx-gui/src/components/project/ProjectPublishedModal.vue +++ b/spx-gui/src/components/project/ProjectPublishedModal.vue @@ -18,20 +18,6 @@ const emit = defineEmits<{ const projectPageRoute = computed(() => getProjectPageRoute(props.project.owner!, props.project.name!)) const projectPageLink = computed(() => `${location.origin}${projectPageRoute.value}`) -// TODO: support vnode as i18n message to simplify such case -const preLinkText = { - en: 'Visit ', - zh: '访问' -} -const linkText = { - en: 'project page', - zh: '项目主页' -} -const postLinkText = { - en: ', or copy the link below to share the project with others.', - zh: ',或者复制下方链接将项目分享给其他人。' -} - const handleCopy = useMessageHandle( () => navigator.clipboard.writeText(projectPageLink.value), { en: 'Failed to copy link to clipboard', zh: '分享链接复制到剪贴板失败' }, @@ -47,8 +33,15 @@ const handleCopy = useMessageHandle( @update:visible="emit('cancelled')" >
- {{ $t(preLinkText) }}{{ $t(linkText) }}{{ $t(postLinkText) }} + + + +