@adminforth/upload 1.0.25 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ChangeLog.md CHANGED
@@ -1,7 +1,12 @@
1
1
 
2
2
 
3
- ## [1.0.23] - 2021-10-07
3
+ ## [1.0.24] - 2023-12-24
4
+
5
+ ### Fixed
6
+ - Add translation
7
+
8
+ ## [1.0.23] - 2023-10-07
4
9
 
5
10
  ### Fixed
6
11
  - preview maxWidth to limit max width of image
7
- - Added accept attribute to input
12
+ - Added accept attribute to input
@@ -8,7 +8,7 @@
8
8
  <!-- Modal header -->
9
9
  <div class="flex items-center justify-between p-3 md:p-4 border-b rounded-t dark:border-gray-600">
10
10
  <h3 class="text-xl font-semibold text-gray-900 dark:text-white">
11
- Generate image with AI
11
+ {{ $('Generate image with AI') }}
12
12
  </h3>
13
13
  <button type="button"
14
14
  @click="emit('close')"
@@ -16,14 +16,14 @@
16
16
  <svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
17
17
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
18
18
  </svg>
19
- <span class="sr-only">Close modal</span>
19
+ <span class="sr-only">{{ $('Close modal') }}</span>
20
20
  </button>
21
21
  </div>
22
22
  <!-- Modal body -->
23
23
  <div class="p-4 md:p-5 space-y-4">
24
24
  <textarea id="message" rows="3" class="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
25
- placeholder="Prompt which will be passed to AI network" v-model="prompt"
26
- title="Prompt which will be passed to AI network"
25
+ :placeholder="$t('Prompt which will be passed to AI network')" v-model="prompt"
26
+ :title="$t('Prompt which will be passed to AI network')"
27
27
  ></textarea>
28
28
 
29
29
  <div class="flex items-center justify-center w-full relative">
@@ -33,7 +33,7 @@
33
33
  >
34
34
  <div role="status" class="absolute -translate-x-1/2 -translate-y-1/2 top-2/4 left-1/2">
35
35
  <svg aria-hidden="true" class="w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>
36
- <span class="sr-only">Loading...</span>
36
+ <span class="sr-only">{{ $('Loading...') }}</span>
37
37
  </div>
38
38
  </div>
39
39
 
@@ -49,7 +49,7 @@
49
49
 
50
50
  <button @click="generateImages" type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4
51
51
  focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center
52
- dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 ms-2">Generate images</button>
52
+ dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 ms-2">{{ $('Generate images') }}</button>
53
53
 
54
54
  </div>
55
55
 
@@ -62,7 +62,7 @@
62
62
  <svg class="w-4 h-4 text-white dark:text-gray-800 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
63
63
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 1 1 5l4 4"/>
64
64
  </svg>
65
- <span class="sr-only">Previous</span>
65
+ <span class="sr-only">{{ $('Previous') }}</span>
66
66
  </span>
67
67
  </button>
68
68
  <button type="button" class="absolute top-0 end-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none"
@@ -72,7 +72,7 @@
72
72
  <svg class="w-4 h-4 text-white dark:text-gray-800 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
73
73
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
74
74
  </svg>
75
- <span class="sr-only">Next</span>
75
+ <span class="sr-only">{{ $('Next') }}</span>
76
76
  </span>
77
77
  </button>
78
78
 
@@ -87,10 +87,10 @@
87
87
  class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center
88
88
  dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800
89
89
  disabled:opacity-50 disabled:cursor-not-allowed"
90
- >Use image</button>
90
+ >{{ $('Use image') }}</button>
91
91
  <button type="button" class="py-2.5 px-5 ms-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
92
92
  @click="emit('close')"
93
- >Cancel</button>
93
+ >{{ $('Cancel') }}</button>
94
94
  </div>
95
95
  </div>
96
96
  </div>
@@ -106,6 +106,9 @@
106
106
  import { ref, onMounted, nextTick } from 'vue'
107
107
  import { Carousel } from 'flowbite';
108
108
  import { callAdminForthApi } from '@/utils';
109
+ import { useI18n } from 'vue-i18n';
110
+
111
+ const { t: $t } = useI18n();
109
112
 
110
113
  const prompt = ref('');
111
114
  const emit = defineEmits(['close', 'uploadImage']);
@@ -130,7 +133,10 @@ onMounted(() => {
130
133
  }).join('\n');
131
134
  }
132
135
 
133
- prompt.value = `Generate image for field "${props.meta.pathColumnLabel}" in ${props.meta.resourceLabel}. No text should be on image.`
136
+ prompt.value = $t('Generate image for field "{field}" in {resource}. No text should be on image.', {
137
+ field: props.meta.pathColumnLabel,
138
+ resource: props.meta.resourceLabel,
139
+ });
134
140
  if (additionalContext) {
135
141
  prompt.value += ` ${additionalContext}`;
136
142
  }
@@ -180,7 +186,7 @@ async function generateImages() {
180
186
 
181
187
  if (resp.error) {
182
188
  window.adminforth.alert({
183
- message: `error: ${JSON.stringify(resp.error)}`,
189
+ message: $t('Error: {error}', { error: JSON.stringify(resp.error) }),
184
190
  variant: 'danger',
185
191
  timeout: 15,
186
192
  });
@@ -25,7 +25,7 @@
25
25
  <svg class="w-4 h-4 me-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
26
26
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
27
27
  </svg>
28
- Download file
28
+ {{ $('Download file') }}
29
29
  </a>
30
30
  </template>
31
31
 
@@ -31,9 +31,9 @@
31
31
  </svg>
32
32
 
33
33
  <template v-if="!uploaded">
34
- <p class="mb-2 text-sm text-gray-500 dark:text-gray-400"><span class="font-semibold">Click to upload</span> or drag and drop</p>
34
+ <p class="mb-2 text-sm text-gray-500 dark:text-gray-400"><span class="font-semibold">{{ $t('Click to upload') }}</span> {{ $t('or drag and drop') }}</p>
35
35
  <p class="text-xs text-gray-500 dark:text-gray-400">
36
- {{ allowedExtensionsLabel }} {{ meta.maxFileSize ? `(up to ${humanifySize(meta.maxFileSize)})` : '' }}
36
+ {{ allowedExtensionsLabel }} {{ meta.maxFileSize ? $t(`(up to {size})`, { size: humanifySize(meta.maxFileSize) }) : '' }}
37
37
  </p>
38
38
  </template>
39
39
 
@@ -50,12 +50,12 @@
50
50
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
51
51
  </svg>
52
52
  <p class="ml-2 text-sm text-green-600 dark:text-green-400 flex items-center">
53
- File uploaded
53
+ {{ $('File uploaded') }}
54
54
  <span class="text-xs text-gray-500 dark:text-gray-400">{{ humanifySize(uploadedSize) }}</span>
55
55
  </p>
56
56
 
57
57
  <button @click.stop.prevent="clear" class="ml-2 text-xs text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-500
58
- hover:underline dark:hover:underline focus:outline-none">Clear</button>
58
+ hover:underline dark:hover:underline focus:outline-none">{{ $t('Clear') }}</button>
59
59
  </div>
60
60
 
61
61
  </div>
@@ -69,6 +69,9 @@
69
69
  import { computed, ref, onMounted, watch } from 'vue'
70
70
  import { callAdminForthApi } from '@/utils'
71
71
  import { IconMagic } from '@iconify-prerendered/vue-mdi';
72
+ import { useI18n } from 'vue-i18n';
73
+
74
+ const { t } = useI18n();
72
75
 
73
76
  const inputId = computed(() => `dropzone-file-${props.meta.pluginInstanceId}`);
74
77
 
@@ -191,7 +194,10 @@ const onFileChange = async (e) => {
191
194
  const allowedExtensions = props.meta.allowedExtensions || []
192
195
  if (allowedExtensions.length > 0 && !allowedExtensions.includes(extension)) {
193
196
  window.adminforth.alert({
194
- message: `Sorry but the file type ${extension} is not allowed. Please upload a file with one of the following extensions: ${allowedExtensionsLabel.value}`,
197
+ message: t('Sorry but the file type {extension} is not allowed. Please upload a file with one of the following extensions: {allowedExtensionsLabel}', {
198
+ extension,
199
+ allowedExtensionsLabel: allowedExtensionsLabel.value,
200
+ }),
195
201
  variant: 'danger'
196
202
  });
197
203
  return;
@@ -200,13 +206,16 @@ const onFileChange = async (e) => {
200
206
  // validate file size
201
207
  if (props.meta.maxFileSize && size > props.meta.maxFileSize) {
202
208
  window.adminforth.alert({
203
- message: `Sorry but the file size ${humanifySize(size)} is too large. Please upload a file with a maximum size of ${humanifySize(props.meta.maxFileSize)}`,
209
+ message: t('Sorry but the file size {size} is too large. Please upload a file with a maximum size of {maxFileSize}', {
210
+ size: humanifySize(size),
211
+ maxFileSize: humanifySize(props.meta.maxFileSize),
212
+ }),
204
213
  variant: 'danger'
205
214
  });
206
215
  return;
207
216
  }
208
217
 
209
- emit('update:inValidity', 'Upload in progress...');
218
+ emit('update:inValidity', t('Upload in progress...'));
210
219
  try {
211
220
  // supports preview
212
221
  if (type.startsWith('image/')) {
@@ -230,7 +239,7 @@ const onFileChange = async (e) => {
230
239
 
231
240
  if (error) {
232
241
  window.adminforth.alert({
233
- message: `File was not uploaded because of error: ${error}`,
242
+ message: t('File was not uploaded because of error: {error}', { error }),
234
243
  variant: 'danger'
235
244
  });
236
245
  imgPreview.value = null;
@@ -258,7 +267,7 @@ const onFileChange = async (e) => {
258
267
  });
259
268
  if (!success) {
260
269
  window.adminforth.alert({
261
- messageHtml: `<div>Sorry but the file was not uploaded because of S3 Request Error: </div>
270
+ messageHtml: `<div>${$t('Sorry but the file was not uploaded because of S3 Request Error:')}</div>
262
271
  <pre style="white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; max-width: 100%;">${
263
272
  xhr.responseText.replace(/</g, '&lt;').replace(/>/g, '&gt;')
264
273
  }</pre>`,
@@ -275,7 +284,7 @@ const onFileChange = async (e) => {
275
284
  } catch (error) {
276
285
  console.error('Error uploading file:', error);
277
286
  window.adminforth.alert({
278
- message: `Sorry but the file was not be uploaded. Please try again: ${error.message}`,
287
+ message: t('Sorry but the file was not be uploaded. Please try again: {error}', { error: error.message }),
279
288
  variant: 'danger'
280
289
  });
281
290
  imgPreview.value = null;
@@ -8,7 +8,7 @@
8
8
  <!-- Modal header -->
9
9
  <div class="flex items-center justify-between p-3 md:p-4 border-b rounded-t dark:border-gray-600">
10
10
  <h3 class="text-xl font-semibold text-gray-900 dark:text-white">
11
- Generate image with AI
11
+ {{ $('Generate image with AI') }}
12
12
  </h3>
13
13
  <button type="button"
14
14
  @click="emit('close')"
@@ -16,14 +16,14 @@
16
16
  <svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
17
17
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
18
18
  </svg>
19
- <span class="sr-only">Close modal</span>
19
+ <span class="sr-only">{{ $('Close modal') }}</span>
20
20
  </button>
21
21
  </div>
22
22
  <!-- Modal body -->
23
23
  <div class="p-4 md:p-5 space-y-4">
24
24
  <textarea id="message" rows="3" class="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
25
- placeholder="Prompt which will be passed to AI network" v-model="prompt"
26
- title="Prompt which will be passed to AI network"
25
+ :placeholder="$t('Prompt which will be passed to AI network')" v-model="prompt"
26
+ :title="$t('Prompt which will be passed to AI network')"
27
27
  ></textarea>
28
28
 
29
29
  <div class="flex items-center justify-center w-full relative">
@@ -33,7 +33,7 @@
33
33
  >
34
34
  <div role="status" class="absolute -translate-x-1/2 -translate-y-1/2 top-2/4 left-1/2">
35
35
  <svg aria-hidden="true" class="w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>
36
- <span class="sr-only">Loading...</span>
36
+ <span class="sr-only">{{ $('Loading...') }}</span>
37
37
  </div>
38
38
  </div>
39
39
 
@@ -49,7 +49,7 @@
49
49
 
50
50
  <button @click="generateImages" type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4
51
51
  focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center
52
- dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 ms-2">Generate images</button>
52
+ dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 ms-2">{{ $('Generate images') }}</button>
53
53
 
54
54
  </div>
55
55
 
@@ -62,7 +62,7 @@
62
62
  <svg class="w-4 h-4 text-white dark:text-gray-800 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
63
63
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 1 1 5l4 4"/>
64
64
  </svg>
65
- <span class="sr-only">Previous</span>
65
+ <span class="sr-only">{{ $('Previous') }}</span>
66
66
  </span>
67
67
  </button>
68
68
  <button type="button" class="absolute top-0 end-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none"
@@ -72,7 +72,7 @@
72
72
  <svg class="w-4 h-4 text-white dark:text-gray-800 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
73
73
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
74
74
  </svg>
75
- <span class="sr-only">Next</span>
75
+ <span class="sr-only">{{ $('Next') }}</span>
76
76
  </span>
77
77
  </button>
78
78
 
@@ -87,10 +87,10 @@
87
87
  class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center
88
88
  dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800
89
89
  disabled:opacity-50 disabled:cursor-not-allowed"
90
- >Use image</button>
90
+ >{{ $('Use image') }}</button>
91
91
  <button type="button" class="py-2.5 px-5 ms-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
92
92
  @click="emit('close')"
93
- >Cancel</button>
93
+ >{{ $('Cancel') }}</button>
94
94
  </div>
95
95
  </div>
96
96
  </div>
@@ -106,6 +106,9 @@
106
106
  import { ref, onMounted, nextTick } from 'vue'
107
107
  import { Carousel } from 'flowbite';
108
108
  import { callAdminForthApi } from '@/utils';
109
+ import { useI18n } from 'vue-i18n';
110
+
111
+ const { t: $t } = useI18n();
109
112
 
110
113
  const prompt = ref('');
111
114
  const emit = defineEmits(['close', 'uploadImage']);
@@ -130,7 +133,10 @@ onMounted(() => {
130
133
  }).join('\n');
131
134
  }
132
135
 
133
- prompt.value = `Generate image for field "${props.meta.pathColumnLabel}" in ${props.meta.resourceLabel}. No text should be on image.`
136
+ prompt.value = $t('Generate image for field "{field}" in {resource}. No text should be on image.', {
137
+ field: props.meta.pathColumnLabel,
138
+ resource: props.meta.resourceLabel,
139
+ });
134
140
  if (additionalContext) {
135
141
  prompt.value += ` ${additionalContext}`;
136
142
  }
@@ -180,7 +186,7 @@ async function generateImages() {
180
186
 
181
187
  if (resp.error) {
182
188
  window.adminforth.alert({
183
- message: `error: ${JSON.stringify(resp.error)}`,
189
+ message: $t('Error: {error}', { error: JSON.stringify(resp.error) }),
184
190
  variant: 'danger',
185
191
  timeout: 15,
186
192
  });
@@ -25,7 +25,7 @@
25
25
  <svg class="w-4 h-4 me-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
26
26
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
27
27
  </svg>
28
- Download file
28
+ {{ $('Download file') }}
29
29
  </a>
30
30
  </template>
31
31
 
@@ -31,9 +31,9 @@
31
31
  </svg>
32
32
 
33
33
  <template v-if="!uploaded">
34
- <p class="mb-2 text-sm text-gray-500 dark:text-gray-400"><span class="font-semibold">Click to upload</span> or drag and drop</p>
34
+ <p class="mb-2 text-sm text-gray-500 dark:text-gray-400"><span class="font-semibold">{{ $t('Click to upload') }}</span> {{ $t('or drag and drop') }}</p>
35
35
  <p class="text-xs text-gray-500 dark:text-gray-400">
36
- {{ allowedExtensionsLabel }} {{ meta.maxFileSize ? `(up to ${humanifySize(meta.maxFileSize)})` : '' }}
36
+ {{ allowedExtensionsLabel }} {{ meta.maxFileSize ? $t(`(up to {size})`, { size: humanifySize(meta.maxFileSize) }) : '' }}
37
37
  </p>
38
38
  </template>
39
39
 
@@ -50,12 +50,12 @@
50
50
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
51
51
  </svg>
52
52
  <p class="ml-2 text-sm text-green-600 dark:text-green-400 flex items-center">
53
- File uploaded
53
+ {{ $('File uploaded') }}
54
54
  <span class="text-xs text-gray-500 dark:text-gray-400">{{ humanifySize(uploadedSize) }}</span>
55
55
  </p>
56
56
 
57
57
  <button @click.stop.prevent="clear" class="ml-2 text-xs text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-500
58
- hover:underline dark:hover:underline focus:outline-none">Clear</button>
58
+ hover:underline dark:hover:underline focus:outline-none">{{ $t('Clear') }}</button>
59
59
  </div>
60
60
 
61
61
  </div>
@@ -69,6 +69,9 @@
69
69
  import { computed, ref, onMounted, watch } from 'vue'
70
70
  import { callAdminForthApi } from '@/utils'
71
71
  import { IconMagic } from '@iconify-prerendered/vue-mdi';
72
+ import { useI18n } from 'vue-i18n';
73
+
74
+ const { t } = useI18n();
72
75
 
73
76
  const inputId = computed(() => `dropzone-file-${props.meta.pluginInstanceId}`);
74
77
 
@@ -191,7 +194,10 @@ const onFileChange = async (e) => {
191
194
  const allowedExtensions = props.meta.allowedExtensions || []
192
195
  if (allowedExtensions.length > 0 && !allowedExtensions.includes(extension)) {
193
196
  window.adminforth.alert({
194
- message: `Sorry but the file type ${extension} is not allowed. Please upload a file with one of the following extensions: ${allowedExtensionsLabel.value}`,
197
+ message: t('Sorry but the file type {extension} is not allowed. Please upload a file with one of the following extensions: {allowedExtensionsLabel}', {
198
+ extension,
199
+ allowedExtensionsLabel: allowedExtensionsLabel.value,
200
+ }),
195
201
  variant: 'danger'
196
202
  });
197
203
  return;
@@ -200,13 +206,16 @@ const onFileChange = async (e) => {
200
206
  // validate file size
201
207
  if (props.meta.maxFileSize && size > props.meta.maxFileSize) {
202
208
  window.adminforth.alert({
203
- message: `Sorry but the file size ${humanifySize(size)} is too large. Please upload a file with a maximum size of ${humanifySize(props.meta.maxFileSize)}`,
209
+ message: t('Sorry but the file size {size} is too large. Please upload a file with a maximum size of {maxFileSize}', {
210
+ size: humanifySize(size),
211
+ maxFileSize: humanifySize(props.meta.maxFileSize),
212
+ }),
204
213
  variant: 'danger'
205
214
  });
206
215
  return;
207
216
  }
208
217
 
209
- emit('update:inValidity', 'Upload in progress...');
218
+ emit('update:inValidity', t('Upload in progress...'));
210
219
  try {
211
220
  // supports preview
212
221
  if (type.startsWith('image/')) {
@@ -230,7 +239,7 @@ const onFileChange = async (e) => {
230
239
 
231
240
  if (error) {
232
241
  window.adminforth.alert({
233
- message: `File was not uploaded because of error: ${error}`,
242
+ message: t('File was not uploaded because of error: {error}', { error }),
234
243
  variant: 'danger'
235
244
  });
236
245
  imgPreview.value = null;
@@ -258,7 +267,7 @@ const onFileChange = async (e) => {
258
267
  });
259
268
  if (!success) {
260
269
  window.adminforth.alert({
261
- messageHtml: `<div>Sorry but the file was not uploaded because of S3 Request Error: </div>
270
+ messageHtml: `<div>${$t('Sorry but the file was not uploaded because of S3 Request Error:')}</div>
262
271
  <pre style="white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; max-width: 100%;">${
263
272
  xhr.responseText.replace(/</g, '&lt;').replace(/>/g, '&gt;')
264
273
  }</pre>`,
@@ -275,7 +284,7 @@ const onFileChange = async (e) => {
275
284
  } catch (error) {
276
285
  console.error('Error uploading file:', error);
277
286
  window.adminforth.alert({
278
- message: `Sorry but the file was not be uploaded. Please try again: ${error.message}`,
287
+ message: t('Sorry but the file was not be uploaded. Please try again: {error}', { error: error.message }),
279
288
  variant: 'danger'
280
289
  });
281
290
  imgPreview.value = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/upload",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",