Skip to content

Commit 47885c2

Browse files
authored
Merge pull request #79 from modx-pro/feat-uppy-localization
Добавлена локализация интерфейса галереи
2 parents 7d2bf32 + f913b2f commit 47885c2

File tree

4 files changed

+95
-22
lines changed

4 files changed

+95
-22
lines changed

core/components/minishop3/lexicon/en/product.inc.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,28 @@
163163

164164
$_lang['ms3_gallery_errors'] = 'Upload Errors';
165165

166+
// Uppy gallery uploader strings
167+
$_lang['ms3_gallery_uppy_drop_paste'] = 'Drop files here or %{browse}';
168+
$_lang['ms3_gallery_uppy_browse'] = 'browse';
169+
$_lang['ms3_gallery_uppy_browse_files'] = 'browse files';
170+
$_lang['ms3_gallery_uppy_browse_folders'] = 'browse folders';
171+
$_lang['ms3_gallery_uppy_upload_complete'] = 'Upload complete';
172+
$_lang['ms3_gallery_uppy_upload_failed'] = 'Upload failed';
173+
$_lang['ms3_gallery_uppy_uploading'] = 'Uploading...';
174+
$_lang['ms3_gallery_uppy_complete'] = 'Complete';
175+
$_lang['ms3_gallery_uppy_cancel'] = 'Cancel';
176+
$_lang['ms3_gallery_uppy_remove'] = 'Remove';
177+
$_lang['ms3_gallery_uppy_edit'] = 'Edit';
178+
$_lang['ms3_gallery_uppy_retry'] = 'Retry';
179+
$_lang['ms3_gallery_uppy_add_more'] = 'Add more';
180+
$_lang['ms3_gallery_uppy_x_files_selected_0'] = '%{smart_count} file selected';
181+
$_lang['ms3_gallery_uppy_x_files_selected_1'] = '%{smart_count} files selected';
182+
$_lang['ms3_gallery_uppy_x_files_selected_2'] = '%{smart_count} files selected';
183+
$_lang['ms3_gallery_uppy_upload_x_files_0'] = 'Upload %{smart_count} file';
184+
$_lang['ms3_gallery_uppy_upload_x_files_1'] = 'Upload %{smart_count} files';
185+
$_lang['ms3_gallery_uppy_upload_x_files_2'] = 'Upload %{smart_count} files';
186+
$_lang['ms3_gallery_uppy_note_max_size'] = 'Maximum size: %{maxSize}';
187+
166188
$_lang['ms3_product_data_vue'] = 'Product Data (Vue)';
167189

168190
// Vue field management widget

core/components/minishop3/lexicon/ru/product.inc.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,26 @@
165165

166166
$_lang['ms3_gallery_errors'] = 'Ошибки при загрузке';
167167

168+
// Строки Uppy для загрузки в галерею
169+
$_lang['ms3_gallery_uppy_drop_paste'] = 'Перетащите файлы сюда или %{browse}';
170+
$_lang['ms3_gallery_uppy_browse'] = 'выбрать';
171+
$_lang['ms3_gallery_uppy_browse_files'] = 'выбрать файлы';
172+
$_lang['ms3_gallery_uppy_browse_folders'] = 'выбрать папки';
173+
$_lang['ms3_gallery_uppy_upload_complete'] = 'Загрузка завершена';
174+
$_lang['ms3_gallery_uppy_upload_failed'] = 'Ошибка загрузки';
175+
$_lang['ms3_gallery_uppy_uploading'] = 'Загрузка...';
176+
$_lang['ms3_gallery_uppy_complete'] = 'Готово';
177+
$_lang['ms3_gallery_uppy_cancel'] = 'Отмена';
178+
$_lang['ms3_gallery_uppy_remove'] = 'Удалить';
179+
$_lang['ms3_gallery_uppy_edit'] = 'Редактировать';
180+
$_lang['ms3_gallery_uppy_retry'] = 'Повторить';
181+
$_lang['ms3_gallery_uppy_add_more'] = 'Добавить ещё';
182+
$_lang['ms3_gallery_uppy_x_files_selected_0'] = '%{smart_count} файл выбран';
183+
$_lang['ms3_gallery_uppy_x_files_selected_1'] = '%{smart_count} файла выбрано';
184+
$_lang['ms3_gallery_uppy_x_files_selected_2'] = '%{smart_count} файлов выбрано';
185+
$_lang['ms3_gallery_uppy_upload_x_files_0'] = 'Загрузить %{smart_count} файл';
186+
$_lang['ms3_gallery_uppy_upload_x_files_1'] = 'Загрузить %{smart_count} файла';
187+
$_lang['ms3_gallery_uppy_upload_x_files_2'] = 'Загрузить %{smart_count} файлов';
188+
$_lang['ms3_gallery_uppy_note_max_size'] = 'Макс. размер: %{maxSize}';
189+
168190
$_lang['ms3_product_data_vue'] = 'Данные товара (Vue)';

vueManager/src/components/gallery/GalleryUploader.vue

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ import Uppy from '@uppy/core'
99
import Dashboard from '@uppy/dashboard'
1010
import ImageEditor from '@uppy/image-editor'
1111
import XHRUpload from '@uppy/xhr-upload'
12+
import { useLexicon } from '@vuetools/useLexicon'
1213
import { onBeforeUnmount, onMounted } from 'vue'
1314
15+
const { _ } = useLexicon()
16+
1417
const props = defineProps({
1518
productId: {
1619
type: [Number, String],
@@ -63,7 +66,47 @@ onBeforeUnmount(() => {
6366
}
6467
})
6568
69+
const buildUppyLocale = () => {
70+
const isRu = (window.MODx?.cultureKey || 'en').toLowerCase().startsWith('ru')
71+
return {
72+
strings: {
73+
dropPasteFiles: _('ms3_gallery_uppy_drop_paste'),
74+
browse: _('ms3_gallery_uppy_browse'),
75+
browseFiles: _('ms3_gallery_uppy_browse_files'),
76+
browseFolders: _('ms3_gallery_uppy_browse_folders'),
77+
uploadComplete: _('ms3_gallery_uppy_upload_complete'),
78+
uploadFailed: _('ms3_gallery_uppy_upload_failed'),
79+
uploading: _('ms3_gallery_uppy_uploading'),
80+
complete: _('ms3_gallery_uppy_complete'),
81+
cancel: _('ms3_gallery_uppy_cancel'),
82+
remove: _('ms3_gallery_uppy_remove'),
83+
edit: _('ms3_gallery_uppy_edit'),
84+
retry: _('ms3_gallery_uppy_retry'),
85+
addMore: _('ms3_gallery_uppy_add_more'),
86+
xFilesSelected: {
87+
0: _('ms3_gallery_uppy_x_files_selected_0'),
88+
1: _('ms3_gallery_uppy_x_files_selected_1'),
89+
2: _('ms3_gallery_uppy_x_files_selected_2'),
90+
},
91+
uploadXFiles: {
92+
0: _('ms3_gallery_uppy_upload_x_files_0'),
93+
1: _('ms3_gallery_uppy_upload_x_files_1'),
94+
2: _('ms3_gallery_uppy_upload_x_files_2'),
95+
},
96+
},
97+
pluralize: isRu
98+
? n =>
99+
n % 10 === 1 && n % 100 !== 11
100+
? 0
101+
: n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20)
102+
? 1
103+
: 2
104+
: n => (n === 1 ? 0 : 1),
105+
}
106+
}
107+
66108
const initUppy = () => {
109+
const locale = buildUppyLocale()
67110
uppy = new Uppy({
68111
id: 'gallery-uploader',
69112
autoProceed: false,
@@ -74,29 +117,14 @@ const initUppy = () => {
74117
minNumberOfFiles: null,
75118
allowedFileTypes: props.allowedFileTypes,
76119
},
77-
locale: {
78-
strings: {
79-
// English localization
80-
dropPasteFiles: 'Drop files here or %{browse}',
81-
browse: 'browse',
82-
uploadComplete: 'Upload complete',
83-
uploadFailed: 'Upload failed',
84-
uploading: 'Uploading...',
85-
complete: 'Complete',
86-
cancel: 'Cancel',
87-
remove: 'Remove',
88-
edit: 'Edit',
89-
retry: 'Retry',
90-
addMore: 'Add more',
91-
xFilesSelected: {
92-
0: '%{smart_count} file selected',
93-
1: '%{smart_count} files selected',
94-
2: '%{smart_count} files selected',
95-
},
96-
},
97-
},
120+
locale,
98121
})
99122
123+
const noteText = _('ms3_gallery_uppy_note_max_size').replace(
124+
'%{maxSize}',
125+
formatBytes(props.maxFileSize)
126+
)
127+
100128
uppy.use(Dashboard, {
101129
target: '#uppy-dashboard',
102130
inline: true,
@@ -105,7 +133,7 @@ const initUppy = () => {
105133
proudlyDisplayPoweredByUppy: false,
106134
showProgressDetails: true,
107135
hideUploadButton: false,
108-
note: `Maximum size: ${formatBytes(props.maxFileSize)}`,
136+
note: noteText,
109137
theme: 'light',
110138
})
111139

vueManager/src/scss/_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
/* Colors — text */
4141
--ms3-text-primary: #374151;
42+
4243
/* Объединённые muted/secondary (ранее были #6c757d, #6b7280, #64748b) */
4344
--ms3-text-muted: #64748b;
4445
--ms3-text-light: #94a3b8;

0 commit comments

Comments
 (0)