From f23ec9063c7c75b99eaa5346ceda269abbbedfa9 Mon Sep 17 00:00:00 2001 From: zzj3720 Date: Mon, 30 Oct 2023 16:54:19 +0800 Subject: [PATCH] feat(collections): completion i18n --- .../page-list/view/create-collection.tsx | 9 +-- .../page-list/view/edit-collection.tsx | 72 +++++++++++-------- .../core/src/pages/workspace/collection.tsx | 36 ++++++---- packages/frontend/i18n/src/resources/en.json | 25 +++++++ 4 files changed, 95 insertions(+), 47 deletions(-) diff --git a/packages/frontend/component/src/components/page-list/view/create-collection.tsx b/packages/frontend/component/src/components/page-list/view/create-collection.tsx index 2fc26e93b8..0f8243894a 100644 --- a/packages/frontend/component/src/components/page-list/view/create-collection.tsx +++ b/packages/frontend/component/src/components/page-list/view/create-collection.tsx @@ -90,19 +90,20 @@ export const CreateCollection = ({ return (
-
Name
+
+ {t['com.affine.editCollectionName.name']()} +
onChange(value), [onChange])} onEnter={save} > {showTips ? (
- Collection is a smart folder where you can manually add pages or - automatically add pages through rules. + {t['com.affine.editCollectionName.createTips']()}
) : null}
diff --git a/packages/frontend/component/src/components/page-list/view/edit-collection.tsx b/packages/frontend/component/src/components/page-list/view/edit-collection.tsx index 9f34733e35..1ce7c4d3d2 100644 --- a/packages/frontend/component/src/components/page-list/view/edit-collection.tsx +++ b/packages/frontend/component/src/components/page-list/view/edit-collection.tsx @@ -229,6 +229,7 @@ const RulesMode = ({ ); }, [open, updateCollection, collection]); const [expandInclude, setExpandInclude] = useState(false); + const count = allowListPages.length + rulesPages.length; return ( <>
@@ -334,16 +335,20 @@ const RulesMode = ({ ) : ( )} - Page + {t[ + 'com.affine.editCollection.rules.include.page' + ]()} +
+
+ {t['com.affine.editCollection.rules.include.is']()}
-
is
- {page?.title || 'Untitled'} + {page?.title || t['Untitled']()}
- Add include page + {t['com.affine.editCollection.rules.include.add']()} @@ -396,7 +401,7 @@ const RulesMode = ({ justifyContent: 'space-between', }} > -
HELP INFO
+
{t['com.affine.collection.helpInfo']()}
- What is "Include"? -
-
- "Include" refers to manually adding pages rather - than automatically adding them through rule matching. You can - manually add pages through the "Add pages" option or - by dragging and dropping (coming soon). + {t['com.affine.editCollection.rules.include.tipsTitle']()}
+
{t['com.affine.editCollection.rules.include.tips']()}
) : null} @@ -463,20 +463,29 @@ const RulesMode = ({ setShowPreview(!showPreview); }} > - Preview + {t['com.affine.editCollection.rules.preview']()}
- Reset + {t['com.affine.editCollection.rules.reset']()}
- After searching, there are currently{' '} - - {allowListPages.length + rulesPages.length} - {' '} - pages. + + After searching, there are currently + count + pages. +
{buttons}
@@ -622,7 +631,7 @@ const PagesMode = ({
- Selected + {t['com.affine.selectPage.selected']()}
- Add include page + {t['com.affine.selectPage.title']()}
{!showFilter && filters.length === 0 ? (
- Selected + {t['com.affine.selectPage.selected']()} - Confirm + {t['Confirm']()}
@@ -874,6 +883,7 @@ const useSearch = (list: PageMeta[]) => { }; }; const EmptyList = ({ search }: { search?: string }) => { + const t = useAFFiNEI18N(); return (
{ fontWeight: 600, }} > - Empty + {t['com.affine.selectPage.empty']()}
{search ? (
- No page titles contain{' '} - - {search} - + + No page titles contain + + search + +
) : null}
diff --git a/packages/frontend/core/src/pages/workspace/collection.tsx b/packages/frontend/core/src/pages/workspace/collection.tsx index b91e029f95..e148cf8a1e 100644 --- a/packages/frontend/core/src/pages/workspace/collection.tsx +++ b/packages/frontend/core/src/pages/workspace/collection.tsx @@ -6,6 +6,8 @@ import { useEditCollection, } from '@affine/component/page-list'; import type { Collection } from '@affine/env/filter'; +import { Trans } from '@affine/i18n'; +import { useAFFiNEI18N } from '@affine/i18n/hooks'; import { CloseIcon, FilterIcon, @@ -104,6 +106,7 @@ const Placeholder = ({ collection }: { collection: Collection }) => { setShowTips(false); localStorage.setItem('hide-empty-collection-help-info', 'true'); }, []); + const t = useAFFiNEI18N(); return (
{ }} > - All Collections + {t['com.affine.collection.allCollections']()}
/
{ color: 'var(--affine-text-primary-color)', }} > - Empty Collection + {t['com.affine.collection.emptyCollection']()}
{ textAlign: 'center', }} > - Collection is a smart folder where you can manually add pages or - automatically add pages through rules. + {t['com.affine.collection.emptyCollectionDescription']()}
{ color: 'var(--affine-icon-color)', }} /> - Add Pages + + {t['com.affine.collection.addPages']()} +
{ color: 'var(--affine-icon-color)', }} /> - Add Rules + + {t['com.affine.collection.addRules']()} +
@@ -230,7 +236,7 @@ const Placeholder = ({ collection }: { collection: Collection }) => { justifyContent: 'space-between', }} > -
HELP INFO
+
{t['com.affine.collection.helpInfo']()}
{ }} >
- Add pages: You can - freely select pages and add them to the collection. + + Add pages: You can + freely select pages and add them to the collection. +
- Add rules: Rules are - based on filtering. After adding rules, pages that meet the - requirements will be automatically added to the current - collection. + + Add rules: Rules are + based on filtering. After adding rules, pages that meet the + requirements will be automatically added to the current + collection. +
diff --git a/packages/frontend/i18n/src/resources/en.json b/packages/frontend/i18n/src/resources/en.json index 7783794f99..954a070cf9 100644 --- a/packages/frontend/i18n/src/resources/en.json +++ b/packages/frontend/i18n/src/resources/en.json @@ -396,6 +396,31 @@ "com.affine.page.group-header.select-all": "Select All", "com.affine.page.toolbar.selected_one": "<0>{{count}} page selected", "com.affine.page.toolbar.selected_others": "<0>{{count}} page(s) selected", + "com.affine.collection.allCollections": "All Collections", + "com.affine.collection.emptyCollection": "Empty Collection", + "com.affine.collection.emptyCollectionDescription": "Collection is a smart folder where you can manually add pages or automatically add pages through rules.", + "com.affine.collection.addPages": "Add Pages", + "com.affine.collection.addPages.tips": "<0>Add pages: You can freely select pages and add them to the collection.", + "com.affine.collection.addRules": "Add Rules", + "com.affine.collection.addRules.tips": "<0>Add rules: Rules are based on filtering. After adding rules, pages that meet the requirements will be automatically added to the current collection.", + "com.affine.collection.helpInfo": "HELP INFO", + "com.affine.editCollectionName.name": "Name", + "com.affine.editCollectionName.name.placeholder": "Collection Name", + "com.affine.editCollectionName.createTips": "Collection is a smart folder where you can manually add pages or automatically add pages through rules.", + "com.affine.editCollection.rules.include.page": "Page", + "com.affine.editCollection.rules.include.is": "is", + "com.affine.editCollection.rules.include.add": "Add include page", + "com.affine.editCollection.rules.include.tipsTitle": "What is \"Include\"?", + "com.affine.editCollection.rules.include.tips": "\"Include\" refers to manually adding pages rather than automatically adding them through rule matching. You can manually add pages through the \"Add pages\" option or by dragging and dropping (coming soon).", + "com.affine.editCollection.rules.preview": "Preview", + "com.affine.editCollection.rules.reset": "Reset", + "com.affine.editCollection.rules.countTips.zero": "Showing <1>{{count}} pages.", + "com.affine.editCollection.rules.countTips.one": "Showing <1>{{count}} page.", + "com.affine.editCollection.rules.countTips.more": "Showing <1>{{count}} pages.", + "com.affine.selectPage.title": "Add include page", + "com.affine.selectPage.selected": "Selected", + "com.affine.selectPage.empty": "Empty", + "com.affine.selectPage.empty.tips": "No page titles contain <1>{{search}}", "Confirm": "Confirm", "Connector": "Connector", "Continue with Google": "Continue with Google",