mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-22 23:17:37 +00:00
feat(webui): integrate i18n into share-manager component
This commit is contained in:
@@ -20,6 +20,7 @@ import { useUserMetadataStore } from '@/ui/stores/user-metadata'
|
||||
import { useTopNavStore } from '@/ui/stores/top-nav'
|
||||
import type { ShareLinkInfo } from '@shumai/dtos'
|
||||
import { toast } from 'sonner'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
|
||||
type ShareManagerProps = {
|
||||
teamId: string
|
||||
@@ -51,7 +52,7 @@ export default function ShareManager({
|
||||
const res = await client.api.shares[':shareId'].$get({
|
||||
param: { shareId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch share link')
|
||||
if (!res.ok) throw new Error(m.failed_fetch_share_link())
|
||||
return (await res.json()) as unknown as ShareLinkInfo
|
||||
},
|
||||
})
|
||||
@@ -123,7 +124,7 @@ export default function ShareManager({
|
||||
order,
|
||||
},
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch folders')
|
||||
if (!res.ok) throw new Error(m.failed_fetch_folders())
|
||||
return (await res.json()) as unknown as AssetInfoPaginatedList
|
||||
},
|
||||
enabled: !!currentFolderId,
|
||||
@@ -148,7 +149,7 @@ export default function ShareManager({
|
||||
order,
|
||||
},
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch files')
|
||||
if (!res.ok) throw new Error(m.failed_fetch_files())
|
||||
return (await res.json()) as unknown as AssetInfoPaginatedList
|
||||
},
|
||||
enabled: !!currentFolderId,
|
||||
@@ -221,11 +222,11 @@ export default function ShareManager({
|
||||
const res = await $removeFromShare({
|
||||
param: { shareId, assetId },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to remove')
|
||||
if (!res.ok) throw new Error(m.failed_remove())
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['folder-children', teamId, currentFolderId] })
|
||||
toast.success('Removed from share')
|
||||
toast.success(m.removed_from_share())
|
||||
},
|
||||
})
|
||||
|
||||
@@ -236,12 +237,12 @@ export default function ShareManager({
|
||||
param: { shareId },
|
||||
json,
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to update')
|
||||
if (!res.ok) throw new Error(m.failed_update())
|
||||
return await res.json()
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['share', shareId] })
|
||||
toast.success('Settings updated')
|
||||
toast.success(m.settings_updated())
|
||||
},
|
||||
})
|
||||
|
||||
@@ -250,7 +251,7 @@ export default function ShareManager({
|
||||
const currentFolderName =
|
||||
currentFolderId === shareRootId
|
||||
? shareLink?.name || ''
|
||||
: folders.find((f) => f.id === currentFolderId)?.name || 'Unknown'
|
||||
: folders.find((f) => f.id === currentFolderId)?.name || m.unknown()
|
||||
|
||||
setAncestorFolders((prev) => [{ id: currentFolderId!, name: currentFolderName }, ...prev])
|
||||
setCurrentFolderId(item.id)
|
||||
@@ -258,7 +259,7 @@ export default function ShareManager({
|
||||
}
|
||||
}
|
||||
|
||||
if (!shareLink) return <div>Loading...</div>
|
||||
if (!shareLink) return <div>{m.loading()}</div>
|
||||
|
||||
return (
|
||||
<DragDropProvider
|
||||
@@ -354,7 +355,7 @@ export default function ShareManager({
|
||||
<DragOverlay>
|
||||
{dragState?.isActive ? (
|
||||
<div className="flex items-center gap-2 rounded-md bg-popover px-3 py-2 text-sm font-medium shadow-md">
|
||||
Moving {dragState.itemCount} item{dragState.itemCount !== 1 ? 's' : ''}
|
||||
{m.moving_items({ count: dragState.itemCount })}
|
||||
</div>
|
||||
) : null}
|
||||
</DragOverlay>
|
||||
|
||||
@@ -788,5 +788,11 @@
|
||||
"n_assets_plural": "{count} Assets",
|
||||
"n_folders_singular": "{count} Folder",
|
||||
"n_folders_plural": "{count} Folders",
|
||||
"failed_upload_file": "Failed to upload file"
|
||||
"failed_upload_file": "Failed to upload file",
|
||||
|
||||
"failed_fetch_share_link": "Failed to fetch share link",
|
||||
"failed_fetch_folders": "Failed to fetch folders",
|
||||
"failed_fetch_files": "Failed to fetch files",
|
||||
"failed_remove": "Failed to remove",
|
||||
"failed_update": "Failed to update"
|
||||
}
|
||||
|
||||
@@ -788,5 +788,11 @@
|
||||
"n_assets_plural": "{count} 个资源",
|
||||
"n_folders_singular": "{count} 个文件夹",
|
||||
"n_folders_plural": "{count} 个文件夹",
|
||||
"failed_upload_file": "上传文件失败"
|
||||
"failed_upload_file": "上传文件失败",
|
||||
|
||||
"failed_fetch_share_link": "获取分享链接失败",
|
||||
"failed_fetch_folders": "获取文件夹失败",
|
||||
"failed_fetch_files": "获取文件失败",
|
||||
"failed_remove": "移除失败",
|
||||
"failed_update": "更新失败"
|
||||
}
|
||||
|
||||
@@ -737,4 +737,9 @@ export * from "./n_assets_plural.js";
|
||||
export * from "./n_folders_singular.js";
|
||||
export * from "./n_folders_plural.js";
|
||||
export * from "./failed_upload_file.js";
|
||||
export * from "./failed_fetch_share_link.js";
|
||||
export * from "./failed_fetch_folders.js";
|
||||
export * from "./failed_fetch_files.js";
|
||||
export * from "./failed_remove.js";
|
||||
export * from "./failed_update.js";
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
|
||||
@@ -738,4 +738,9 @@ export * from './n_assets_singular.js'
|
||||
export * from './n_assets_plural.js'
|
||||
export * from './n_folders_singular.js'
|
||||
export * from './n_folders_plural.js'
|
||||
export * from './failed_upload_file.js'
|
||||
export * from './failed_upload_file.js'
|
||||
export * from './failed_fetch_share_link.js'
|
||||
export * from './failed_fetch_folders.js'
|
||||
export * from './failed_fetch_files.js'
|
||||
export * from './failed_remove.js'
|
||||
export * from './failed_update.js'
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Failed to fetch files" |
|
||||
*
|
||||
* @param {Failed_Fetch_FilesInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const failed_fetch_files: ((inputs?: Failed_Fetch_FilesInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Failed_Fetch_FilesInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Failed_Fetch_FilesInputs = {};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Failed_Fetch_FilesInputs */
|
||||
|
||||
const en_failed_fetch_files = /** @type {(inputs: Failed_Fetch_FilesInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Failed to fetch files`)
|
||||
};
|
||||
|
||||
const zh_failed_fetch_files = /** @type {(inputs: Failed_Fetch_FilesInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`获取文件失败`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Failed to fetch files" |
|
||||
*
|
||||
* @param {Failed_Fetch_FilesInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const failed_fetch_files = /** @type {((inputs?: Failed_Fetch_FilesInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Failed_Fetch_FilesInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_failed_fetch_files(inputs)
|
||||
return zh_failed_fetch_files(inputs)
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Failed to fetch folders" |
|
||||
*
|
||||
* @param {Failed_Fetch_FoldersInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const failed_fetch_folders: ((inputs?: Failed_Fetch_FoldersInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Failed_Fetch_FoldersInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Failed_Fetch_FoldersInputs = {};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Failed_Fetch_FoldersInputs */
|
||||
|
||||
const en_failed_fetch_folders = /** @type {(inputs: Failed_Fetch_FoldersInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Failed to fetch folders`)
|
||||
};
|
||||
|
||||
const zh_failed_fetch_folders = /** @type {(inputs: Failed_Fetch_FoldersInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`获取文件夹失败`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Failed to fetch folders" |
|
||||
*
|
||||
* @param {Failed_Fetch_FoldersInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const failed_fetch_folders = /** @type {((inputs?: Failed_Fetch_FoldersInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Failed_Fetch_FoldersInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_failed_fetch_folders(inputs)
|
||||
return zh_failed_fetch_folders(inputs)
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Failed to fetch share link" |
|
||||
*
|
||||
* @param {Failed_Fetch_Share_LinkInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const failed_fetch_share_link: ((inputs?: Failed_Fetch_Share_LinkInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Failed_Fetch_Share_LinkInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Failed_Fetch_Share_LinkInputs = {};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Failed_Fetch_Share_LinkInputs */
|
||||
|
||||
const en_failed_fetch_share_link = /** @type {(inputs: Failed_Fetch_Share_LinkInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Failed to fetch share link`)
|
||||
};
|
||||
|
||||
const zh_failed_fetch_share_link = /** @type {(inputs: Failed_Fetch_Share_LinkInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`获取分享链接失败`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Failed to fetch share link" |
|
||||
*
|
||||
* @param {Failed_Fetch_Share_LinkInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const failed_fetch_share_link = /** @type {((inputs?: Failed_Fetch_Share_LinkInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Failed_Fetch_Share_LinkInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_failed_fetch_share_link(inputs)
|
||||
return zh_failed_fetch_share_link(inputs)
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Failed to remove" |
|
||||
*
|
||||
* @param {Failed_RemoveInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const failed_remove: ((inputs?: Failed_RemoveInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Failed_RemoveInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Failed_RemoveInputs = {};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Failed_RemoveInputs */
|
||||
|
||||
const en_failed_remove = /** @type {(inputs: Failed_RemoveInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Failed to remove`)
|
||||
};
|
||||
|
||||
const zh_failed_remove = /** @type {(inputs: Failed_RemoveInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`移除失败`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Failed to remove" |
|
||||
*
|
||||
* @param {Failed_RemoveInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const failed_remove = /** @type {((inputs?: Failed_RemoveInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Failed_RemoveInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_failed_remove(inputs)
|
||||
return zh_failed_remove(inputs)
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Failed to update" |
|
||||
*
|
||||
* @param {Failed_UpdateInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const failed_update: ((inputs?: Failed_UpdateInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Failed_UpdateInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Failed_UpdateInputs = {};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Failed_UpdateInputs */
|
||||
|
||||
const en_failed_update = /** @type {(inputs: Failed_UpdateInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Failed to update`)
|
||||
};
|
||||
|
||||
const zh_failed_update = /** @type {(inputs: Failed_UpdateInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`更新失败`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Failed to update" |
|
||||
*
|
||||
* @param {Failed_UpdateInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const failed_update = /** @type {((inputs?: Failed_UpdateInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Failed_UpdateInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_failed_update(inputs)
|
||||
return zh_failed_update(inputs)
|
||||
});
|
||||
Reference in New Issue
Block a user