fix: 完善后台预览工具条翻译
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import PhotoSwipe from 'photoswipe';
|
||||
import PhotoSwipeLightbox from 'photoswipe/lightbox';
|
||||
import 'photoswipe/style.css';
|
||||
import { i18n } from '@/locales';
|
||||
|
||||
export interface MediaViewerItem {
|
||||
url?: string;
|
||||
@@ -194,6 +195,10 @@ function icon(paths: string): string {
|
||||
return `<svg viewBox="0 0 24 24" aria-hidden="true">${paths}</svg>`;
|
||||
}
|
||||
|
||||
function translate(key: string): string {
|
||||
return i18n.global.t(key);
|
||||
}
|
||||
|
||||
function registerToolbarButton(
|
||||
lightbox: PhotoSwipeLightbox,
|
||||
options: {
|
||||
@@ -244,7 +249,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void {
|
||||
lightbox.on('uiRegister', () => {
|
||||
registerToolbarButton(lightbox, {
|
||||
name: 'rotate-left',
|
||||
title: '向左旋转',
|
||||
title: translate('pages.mediaViewer.rotateLeft'),
|
||||
order: 41,
|
||||
html: icon('<path d="M4 7v5h5"/><path d="M5.5 12a7 7 0 1 0 2-5"/><path d="M4 7l3.5-.2"/>'),
|
||||
imageOnly: true,
|
||||
@@ -252,7 +257,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void {
|
||||
});
|
||||
registerToolbarButton(lightbox, {
|
||||
name: 'rotate-right',
|
||||
title: '向右旋转',
|
||||
title: translate('pages.mediaViewer.rotateRight'),
|
||||
order: 42,
|
||||
html: icon('<path d="M20 7v5h-5"/><path d="M18.5 12a7 7 0 1 1-2-5"/><path d="M20 7l-3.5-.2"/>'),
|
||||
imageOnly: true,
|
||||
@@ -260,7 +265,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void {
|
||||
});
|
||||
registerToolbarButton(lightbox, {
|
||||
name: 'reset',
|
||||
title: '还原',
|
||||
title: translate('pages.mediaViewer.reset'),
|
||||
order: 43,
|
||||
html: icon('<path d="M8 3h8v4"/><path d="M16 3l-9 9 5 5 9-9"/><path d="M5 19h14"/>'),
|
||||
imageOnly: true,
|
||||
@@ -268,7 +273,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void {
|
||||
});
|
||||
registerToolbarButton(lightbox, {
|
||||
name: 'zoom-out',
|
||||
title: '缩小',
|
||||
title: translate('pages.mediaViewer.zoomOut'),
|
||||
order: 44,
|
||||
html: icon('<circle cx="11" cy="11" r="6"/><path d="M8.5 11h5"/><path d="M16 16l4 4"/>'),
|
||||
imageOnly: true,
|
||||
@@ -276,7 +281,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void {
|
||||
});
|
||||
registerToolbarButton(lightbox, {
|
||||
name: 'zoom-in',
|
||||
title: '放大',
|
||||
title: translate('pages.mediaViewer.zoomIn'),
|
||||
order: 45,
|
||||
html: icon('<circle cx="11" cy="11" r="6"/><path d="M8.5 11h5"/><path d="M11 8.5v5"/><path d="M16 16l4 4"/>'),
|
||||
imageOnly: true,
|
||||
@@ -284,7 +289,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void {
|
||||
});
|
||||
registerToolbarButton(lightbox, {
|
||||
name: 'download',
|
||||
title: '下载',
|
||||
title: translate('pages.mediaViewer.download'),
|
||||
order: 46,
|
||||
html: icon('<path d="M12 4v10"/><path d="M8 10l4 4 4-4"/><path d="M5 20h14"/>'),
|
||||
imageOnly: true,
|
||||
@@ -292,7 +297,7 @@ function registerToolbar(lightbox: PhotoSwipeLightbox): void {
|
||||
});
|
||||
registerToolbarButton(lightbox, {
|
||||
name: 'bottom-close',
|
||||
title: '关闭',
|
||||
title: translate('pages.mediaViewer.close'),
|
||||
order: 47,
|
||||
html: icon('<path d="M6 6l12 12"/><path d="M18 6L6 18"/>'),
|
||||
onClick: (instance) => instance?.close?.(),
|
||||
|
||||
Reference in New Issue
Block a user