From ae4a1b6fbe67f5bc17d07778511e514f6acec422 Mon Sep 17 00:00:00 2001 From: Rozstone <42225395+wststone@users.noreply.github.com> Date: Sun, 21 Aug 2022 14:40:17 +0800 Subject: [PATCH] dialog i18 support (#915) --- .../Primitives/AlertDialog/AlertDialog.tsx | 17 +++++++++-------- packages/tldraw/src/translations/main.json | 7 ++++++- packages/tldraw/src/translations/zh-cn.json | 13 +++++++++---- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/packages/tldraw/src/components/Primitives/AlertDialog/AlertDialog.tsx b/packages/tldraw/src/components/Primitives/AlertDialog/AlertDialog.tsx index 2970b70df..10658cd5f 100644 --- a/packages/tldraw/src/components/Primitives/AlertDialog/AlertDialog.tsx +++ b/packages/tldraw/src/components/Primitives/AlertDialog/AlertDialog.tsx @@ -1,5 +1,6 @@ import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog' import * as React from 'react' +import { FormattedMessage, useIntl } from 'react-intl' import { DialogState, useDialog } from '~hooks' import { styled } from '~styles' @@ -42,13 +43,13 @@ export const AlertDialogDescription = StyledDescription export const AlertDialogAction = AlertDialogPrimitive.Action export const AlertDialogCancel = AlertDialogPrimitive.Cancel -const descriptions: Record = { - 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 }) => { const { setDialogState, dialogState, onCancel, onNo, onYes } = useDialog() + const intl = useIntl() + const descriptions: Record = { + saveFirstTime: intl.formatMessage({ id: 'dialog.save.firsttime' }), + saveAgain: intl.formatMessage({ id: 'dialog.save.again' }), + } return ( @@ -73,7 +74,7 @@ export const AlertDialog = ({ container }: { container: any }) => { setDialogState(null) }} > - Cancel + )} @@ -86,7 +87,7 @@ export const AlertDialog = ({ container }: { container: any }) => { setDialogState(null) }} > - No + )} @@ -99,7 +100,7 @@ export const AlertDialog = ({ container }: { container: any }) => { setDialogState(null) }} > - Yes + )} diff --git a/packages/tldraw/src/translations/main.json b/packages/tldraw/src/translations/main.json index c53cf6a3a..0dd49b5ca 100644 --- a/packages/tldraw/src/translations/main.json +++ b/packages/tldraw/src/translations/main.json @@ -117,5 +117,10 @@ "distribute.x": "Distribute Horizontal", "distribute.y": "Distribute Vertical", "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" } diff --git a/packages/tldraw/src/translations/zh-cn.json b/packages/tldraw/src/translations/zh-cn.json index 6fd0fd6c4..a27d94f78 100644 --- a/packages/tldraw/src/translations/zh-cn.json +++ b/packages/tldraw/src/translations/zh-cn.json @@ -44,7 +44,7 @@ "select.all": "选中全部", "select.none": "取消选中", "delete": "删除", - "new.project": "新工程", + "new.project": "新项目", "open": "打开", "save": "保存", "save.as": "保存为", @@ -55,8 +55,8 @@ "duplicate": "复制", "cancel": "取消", "copy.invite.link": "复制邀请链接", - "create.multiplayer.project": "创建多人工程", - "copy.multiplayer.project": "复制到多人工程", + "create.multiplayer.project": "创建多人项目", + "copy.multiplayer.project": "复制到多人项目", "select": "选择", "eraser": "橡皮", "draw": "画笔", @@ -103,5 +103,10 @@ "dark": "暗黑", "copy.readonly.link": "复制只读链接", "image": "图片", - "align.distribute": "对齐 / 分散" + "align.distribute": "对齐 / 分散", + "dialog.save.firsttime": "您是否想保存当前的项目?", + "dialog.save.again": "您是否想保存对当前项目的更改?", + "dialog.cancel": "取消", + "dialog.no": "否", + "dialog.yes": "是" }