Pagename i18 support (#907)
* add i18 support for page * add more cn translations
This commit is contained in:
parent
97b0b52a6e
commit
56747e67a5
2 changed files with 15 additions and 5 deletions
|
@ -22,6 +22,8 @@ const currentPageIdSelector = (s: TDSnapshot) => s.document.pages[s.appState.cur
|
|||
export function PageMenu() {
|
||||
const app = useTldrawApp()
|
||||
|
||||
const intl = useIntl()
|
||||
|
||||
const rIsOpen = React.useRef(false)
|
||||
|
||||
const [isOpen, setIsOpen] = React.useState(false)
|
||||
|
@ -49,7 +51,7 @@ export function PageMenu() {
|
|||
return (
|
||||
<DropdownMenu.Root dir="ltr" open={isOpen} onOpenChange={handleOpenChange}>
|
||||
<DropdownMenu.Trigger dir="ltr" asChild id="TD-Page">
|
||||
<ToolButton variant="text">{currentPageName || 'Page'}</ToolButton>
|
||||
<ToolButton variant="text">{currentPageName || intl.formatMessage({ id: 'page' })}</ToolButton>
|
||||
</DropdownMenu.Trigger>
|
||||
<DMContent variant="menu" align="start" sideOffset={4}>
|
||||
{isOpen && <PageMenuContent onClose={handleClose} />}
|
||||
|
@ -66,9 +68,11 @@ function PageMenuContent({ onClose }: { onClose: () => void }) {
|
|||
|
||||
const currentPageId = app.useStore(currentPageIdSelector)
|
||||
|
||||
const defaultPageName = intl.formatMessage({ id: 'page' })
|
||||
|
||||
const handleCreatePage = React.useCallback(() => {
|
||||
const pageName =
|
||||
intl.formatMessage({ id: 'page' }) + ' ' + (Object.keys(app.document.pages).length + 1)
|
||||
defaultPageName + ' ' + (Object.keys(app.document.pages).length + 1)
|
||||
app.createPage(undefined, pageName)
|
||||
}, [app])
|
||||
|
||||
|
@ -125,7 +129,7 @@ function PageMenuContent({ onClose }: { onClose: () => void }) {
|
|||
isDropBelow={dropIndex !== null && i === dropIndex - 1}
|
||||
>
|
||||
<DropdownMenu.RadioItem
|
||||
title={page.name || 'Page'}
|
||||
title={page.name || defaultPageName}
|
||||
value={page.id}
|
||||
key={page.id}
|
||||
id={page.id}
|
||||
|
@ -137,7 +141,7 @@ function PageMenuContent({ onClose }: { onClose: () => void }) {
|
|||
draggable={true}
|
||||
>
|
||||
<PageButton>
|
||||
<span id={page.id}>{page.name || 'Page'}</span>
|
||||
<span id={page.id}>{page.name || defaultPageName}</span>
|
||||
<DropdownMenu.ItemIndicator>
|
||||
<SmallIcon>
|
||||
<CheckIcon />
|
||||
|
|
|
@ -10,16 +10,20 @@
|
|||
"zoom.in": "放大",
|
||||
"zoom.out": "缩小",
|
||||
"to": "缩放至",
|
||||
"menu.tools": "工具",
|
||||
"menu.transform": "转换",
|
||||
"menu.file": "文件",
|
||||
"menu.edit": "编辑",
|
||||
"menu.view": "视图",
|
||||
"menu.preferences": "偏好",
|
||||
"menu.sign.in": "登录",
|
||||
"menu.sign.out": "登出",
|
||||
"search": "搜索",
|
||||
"become.a.sponsor": "成为赞助者",
|
||||
"zoom.to.selection": "缩放选中",
|
||||
"zoom.to.fit": "自适应缩放",
|
||||
"zoom.to": "缩放至",
|
||||
"zoom.to.content": "缩放至内容",
|
||||
"preferences.dark.mode": "暗黑模式",
|
||||
"preferences.focus.mode": "专注模式",
|
||||
"preferences.debug.mode": "调试模式",
|
||||
|
@ -97,5 +101,7 @@
|
|||
"auto": "自动",
|
||||
"light": "明亮",
|
||||
"dark": "暗黑",
|
||||
"copy.readonly.link": "复制只读链接"
|
||||
"copy.readonly.link": "复制只读链接",
|
||||
"image": "图片",
|
||||
"align.distribute": "对齐 / 分散"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue