feat(i18n): add support for pasted text and images in message attachments across multiple languages
- Introduced new translations for "Pasted Text" and "Pasted Image" in English, Japanese, Russian, Simplified Chinese, and Traditional Chinese. - Updated FileManager to format file names based on their type, enhancing user experience when handling pasted content.
This commit is contained in:
parent
8df09b4ecc
commit
570d6aeaf1
@ -400,6 +400,10 @@
|
|||||||
"title": "Mermaid Diagram"
|
"title": "Mermaid Diagram"
|
||||||
},
|
},
|
||||||
"message": {
|
"message": {
|
||||||
|
"attachments": {
|
||||||
|
"pasted_text": "Pasted Text",
|
||||||
|
"pasted_image": "Pasted Image"
|
||||||
|
},
|
||||||
"api.check.model.title": "Select the model to use for detection",
|
"api.check.model.title": "Select the model to use for detection",
|
||||||
"api.connection.failed": "Connection failed",
|
"api.connection.failed": "Connection failed",
|
||||||
"api.connection.success": "Connection successful",
|
"api.connection.success": "Connection successful",
|
||||||
|
|||||||
@ -400,6 +400,10 @@
|
|||||||
"title": "Mermaid図"
|
"title": "Mermaid図"
|
||||||
},
|
},
|
||||||
"message": {
|
"message": {
|
||||||
|
"attachments": {
|
||||||
|
"pasted_text": "クリップボードファイル",
|
||||||
|
"pasted_image": "クリップボード画像"
|
||||||
|
},
|
||||||
"api.check.model.title": "検出に使用するモデルを選択してください",
|
"api.check.model.title": "検出に使用するモデルを選択してください",
|
||||||
"api.connection.failed": "接続に失敗しました",
|
"api.connection.failed": "接続に失敗しました",
|
||||||
"api.connection.success": "接続に成功しました",
|
"api.connection.success": "接続に成功しました",
|
||||||
|
|||||||
@ -406,6 +406,10 @@
|
|||||||
"title": "GPUStack"
|
"title": "GPUStack"
|
||||||
},
|
},
|
||||||
"message": {
|
"message": {
|
||||||
|
"attachments": {
|
||||||
|
"pasted_text": "Вырезанный текст",
|
||||||
|
"pasted_image": "Вырезанное изображение"
|
||||||
|
},
|
||||||
"api.check.model.title": "Выберите модель для проверки",
|
"api.check.model.title": "Выберите модель для проверки",
|
||||||
"api.connection.failed": "Соединение не удалось",
|
"api.connection.failed": "Соединение не удалось",
|
||||||
"api.connection.success": "Соединение успешно",
|
"api.connection.success": "Соединение успешно",
|
||||||
|
|||||||
@ -400,6 +400,10 @@
|
|||||||
"title": "Mermaid 图表"
|
"title": "Mermaid 图表"
|
||||||
},
|
},
|
||||||
"message": {
|
"message": {
|
||||||
|
"attachments": {
|
||||||
|
"pasted_text": "剪切板文件",
|
||||||
|
"pasted_image": "剪切板图片"
|
||||||
|
},
|
||||||
"api.check.model.title": "请选择要检测的模型",
|
"api.check.model.title": "请选择要检测的模型",
|
||||||
"api.connection.failed": "连接失败",
|
"api.connection.failed": "连接失败",
|
||||||
"api.connection.success": "连接成功",
|
"api.connection.success": "连接成功",
|
||||||
|
|||||||
@ -400,6 +400,10 @@
|
|||||||
"title": "Mermaid 圖表"
|
"title": "Mermaid 圖表"
|
||||||
},
|
},
|
||||||
"message": {
|
"message": {
|
||||||
|
"attachments": {
|
||||||
|
"pasted_text": "剪切板文件",
|
||||||
|
"pasted_image": "剪切板圖片"
|
||||||
|
},
|
||||||
"api.check.model.title": "請選擇要偵測的模型",
|
"api.check.model.title": "請選擇要偵測的模型",
|
||||||
"api.connection.failed": "連接失敗",
|
"api.connection.failed": "連接失敗",
|
||||||
"api.connection.success": "連接成功",
|
"api.connection.success": "連接成功",
|
||||||
|
|||||||
@ -118,7 +118,7 @@ const FilesPage: FC = () => {
|
|||||||
key: file.id,
|
key: file.id,
|
||||||
file: (
|
file: (
|
||||||
<FileNameText className="text-nowrap" onClick={() => window.api.file.openPath(file.path)}>
|
<FileNameText className="text-nowrap" onClick={() => window.api.file.openPath(file.path)}>
|
||||||
{file.origin_name}
|
{FileManager.formatFileName(file)}
|
||||||
</FileNameText>
|
</FileNameText>
|
||||||
),
|
),
|
||||||
size: formatFileSize(file.size),
|
size: formatFileSize(file.size),
|
||||||
|
|||||||
@ -30,7 +30,7 @@ const MessageAttachments: FC<Props> = ({ message }) => {
|
|||||||
uid: file.id,
|
uid: file.id,
|
||||||
url: 'file://' + FileManager.getSafePath(file),
|
url: 'file://' + FileManager.getSafePath(file),
|
||||||
status: 'done',
|
status: 'done',
|
||||||
name: file.origin_name
|
name: FileManager.formatFileName(file)
|
||||||
}))}
|
}))}
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
import db from '@renderer/databases'
|
import db from '@renderer/databases'
|
||||||
|
import i18n from '@renderer/i18n'
|
||||||
import store from '@renderer/store'
|
import store from '@renderer/store'
|
||||||
import { FileType } from '@renderer/types'
|
import { FileType } from '@renderer/types'
|
||||||
import { getFileDirectory } from '@renderer/utils'
|
import { getFileDirectory } from '@renderer/utils'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
class FileManager {
|
class FileManager {
|
||||||
static async selectFiles(options?: Electron.OpenDialogOptions): Promise<FileType[] | null> {
|
static async selectFiles(options?: Electron.OpenDialogOptions): Promise<FileType[] | null> {
|
||||||
@ -110,6 +112,24 @@ class FileManager {
|
|||||||
|
|
||||||
await db.files.update(file.id, file)
|
await db.files.update(file.id, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static formatFileName(file: FileType) {
|
||||||
|
if (!file || !file.origin_name) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const date = dayjs(file.created_at).format('YYYY-MM-DD')
|
||||||
|
|
||||||
|
if (file.origin_name.includes('pasted_text')) {
|
||||||
|
return date + ' ' + i18n.t('message.attachments.pasted_text') + file.ext
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.origin_name.startsWith('temp_file') && file.origin_name.includes('image')) {
|
||||||
|
return date + ' ' + i18n.t('message.attachments.pasted_image') + file.ext
|
||||||
|
}
|
||||||
|
|
||||||
|
return file.origin_name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FileManager
|
export default FileManager
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user