dialog i18 support (#915)
This commit is contained in:
parent
0699dcce17
commit
ae4a1b6fbe
3 changed files with 24 additions and 13 deletions
|
@ -1,5 +1,6 @@
|
||||||
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
|
import { FormattedMessage, useIntl } from 'react-intl'
|
||||||
import { DialogState, useDialog } from '~hooks'
|
import { DialogState, useDialog } from '~hooks'
|
||||||
import { styled } from '~styles'
|
import { styled } from '~styles'
|
||||||
|
|
||||||
|
@ -42,13 +43,13 @@ export const AlertDialogDescription = StyledDescription
|
||||||
export const AlertDialogAction = AlertDialogPrimitive.Action
|
export const AlertDialogAction = AlertDialogPrimitive.Action
|
||||||
export const AlertDialogCancel = AlertDialogPrimitive.Cancel
|
export const AlertDialogCancel = AlertDialogPrimitive.Cancel
|
||||||
|
|
||||||
const descriptions: Record<DialogState, string> = {
|
|
||||||
saveFirstTime: 'Do you want to save your current project?',
|
|
||||||
saveAgain: 'Do you want to save changes to your current project?',
|
|
||||||
}
|
|
||||||
|
|
||||||
export const AlertDialog = ({ container }: { container: any }) => {
|
export const AlertDialog = ({ container }: { container: any }) => {
|
||||||
const { setDialogState, dialogState, onCancel, onNo, onYes } = useDialog()
|
const { setDialogState, dialogState, onCancel, onNo, onYes } = useDialog()
|
||||||
|
const intl = useIntl()
|
||||||
|
const descriptions: Record<DialogState, string> = {
|
||||||
|
saveFirstTime: intl.formatMessage({ id: 'dialog.save.firsttime' }),
|
||||||
|
saveAgain: intl.formatMessage({ id: 'dialog.save.again' }),
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AlertDialogRoot open={dialogState !== null}>
|
<AlertDialogRoot open={dialogState !== null}>
|
||||||
|
@ -73,7 +74,7 @@ export const AlertDialog = ({ container }: { container: any }) => {
|
||||||
setDialogState(null)
|
setDialogState(null)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Cancel
|
<FormattedMessage id="dialog.cancel" />
|
||||||
</Button>
|
</Button>
|
||||||
</AlertDialogCancel>
|
</AlertDialogCancel>
|
||||||
)}
|
)}
|
||||||
|
@ -86,7 +87,7 @@ export const AlertDialog = ({ container }: { container: any }) => {
|
||||||
setDialogState(null)
|
setDialogState(null)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
No
|
<FormattedMessage id="dialog.no" />
|
||||||
</Button>
|
</Button>
|
||||||
</AlertDialogAction>
|
</AlertDialogAction>
|
||||||
)}
|
)}
|
||||||
|
@ -99,7 +100,7 @@ export const AlertDialog = ({ container }: { container: any }) => {
|
||||||
setDialogState(null)
|
setDialogState(null)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Yes
|
<FormattedMessage id="dialog.yes" />
|
||||||
</Button>
|
</Button>
|
||||||
</AlertDialogAction>
|
</AlertDialogAction>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -117,5 +117,10 @@
|
||||||
"distribute.x": "Distribute Horizontal",
|
"distribute.x": "Distribute Horizontal",
|
||||||
"distribute.y": "Distribute Vertical",
|
"distribute.y": "Distribute Vertical",
|
||||||
"stretch.x": "Stretch Horizontal",
|
"stretch.x": "Stretch Horizontal",
|
||||||
"stretch.y": "Stretch Vertical"
|
"stretch.y": "Stretch Vertical",
|
||||||
|
"dialog.save.firsttime": "Do you want to save your current project?",
|
||||||
|
"dialog.save.again": "Do you want to save changes to your current project?",
|
||||||
|
"dialog.cancel": "Cancel",
|
||||||
|
"dialog.no": "No",
|
||||||
|
"dialog.yes": "Yes"
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
"select.all": "选中全部",
|
"select.all": "选中全部",
|
||||||
"select.none": "取消选中",
|
"select.none": "取消选中",
|
||||||
"delete": "删除",
|
"delete": "删除",
|
||||||
"new.project": "新工程",
|
"new.project": "新项目",
|
||||||
"open": "打开",
|
"open": "打开",
|
||||||
"save": "保存",
|
"save": "保存",
|
||||||
"save.as": "保存为",
|
"save.as": "保存为",
|
||||||
|
@ -55,8 +55,8 @@
|
||||||
"duplicate": "复制",
|
"duplicate": "复制",
|
||||||
"cancel": "取消",
|
"cancel": "取消",
|
||||||
"copy.invite.link": "复制邀请链接",
|
"copy.invite.link": "复制邀请链接",
|
||||||
"create.multiplayer.project": "创建多人工程",
|
"create.multiplayer.project": "创建多人项目",
|
||||||
"copy.multiplayer.project": "复制到多人工程",
|
"copy.multiplayer.project": "复制到多人项目",
|
||||||
"select": "选择",
|
"select": "选择",
|
||||||
"eraser": "橡皮",
|
"eraser": "橡皮",
|
||||||
"draw": "画笔",
|
"draw": "画笔",
|
||||||
|
@ -103,5 +103,10 @@
|
||||||
"dark": "暗黑",
|
"dark": "暗黑",
|
||||||
"copy.readonly.link": "复制只读链接",
|
"copy.readonly.link": "复制只读链接",
|
||||||
"image": "图片",
|
"image": "图片",
|
||||||
"align.distribute": "对齐 / 分散"
|
"align.distribute": "对齐 / 分散",
|
||||||
|
"dialog.save.firsttime": "您是否想保存当前的项目?",
|
||||||
|
"dialog.save.again": "您是否想保存对当前项目的更改?",
|
||||||
|
"dialog.cancel": "取消",
|
||||||
|
"dialog.no": "否",
|
||||||
|
"dialog.yes": "是"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue