Skip to content

Commit be1c571

Browse files
committed
fix: add i18n translations for confirmation and success messages
1 parent 58d9dc3 commit be1c571

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

adminforth/spa/src/components/ResourceListTable.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
272272
import { computed, onMounted, ref, watch, type Ref } from 'vue';
273273
import { callAdminForthApi } from '@/utils';
274-
274+
import { useI18n } from 'vue-i18n';
275275
import ValueRenderer from '@/components/ValueRenderer.vue';
276276
import { getCustomComponent } from '@/utils';
277277
import { useCoreStore } from '@/stores/core';
@@ -293,7 +293,7 @@ import type { AdminForthResourceCommon } from '@/types/Common';
293293
import adminforth from '@/adminforth';
294294
295295
const coreStore = useCoreStore();
296-
296+
const { t } = useI18n();
297297
const props = defineProps<{
298298
page: number,
299299
resource: AdminForthResourceCommon,
@@ -456,9 +456,9 @@ async function onClick(e,row) {
456456
457457
async function deleteRecord(row) {
458458
const data = await adminforth.confirm({
459-
message: 'Are you sure you want to delete this item?',
460-
yes: 'Delete',
461-
no: 'Cancel',
459+
message: t('Are you sure you want to delete this item?'),
460+
yes: t('Delete'),
461+
no: t('Cancel'),
462462
});
463463
if (data) {
464464
try {
@@ -472,13 +472,13 @@ async function deleteRecord(row) {
472472
});
473473
if (!res.error){
474474
emits('update:records', true)
475-
showSuccesTost('Record deleted successfully')
475+
showSuccesTost(t('Record deleted successfully'))
476476
} else {
477477
showErrorTost(res.error)
478478
}
479479
480480
} catch (e) {
481-
showErrorTost(`Something went wrong, please try again later`);
481+
showErrorTost(t('Something went wrong, please try again later'));
482482
console.error(e);
483483
};
484484
}

adminforth/spa/src/views/CreateView.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ import { computed } from 'vue';
8686
import { showErrorTost } from '@/composables/useFrontendApi';
8787
import ThreeDotsMenu from '@/components/ThreeDotsMenu.vue';
8888
import adminforth from '@/adminforth';
89-
89+
import { useI18n } from 'vue-i18n';
9090
9191
const isValid = ref(false);
9292
const validating = ref(false);
@@ -101,6 +101,7 @@ const record = ref({});
101101
102102
const coreStore = useCoreStore();
103103
104+
const { t } = useI18n();
104105
const initalValues = computed(() => {
105106
if (!route.query.values) {
106107
return {};
@@ -157,7 +158,7 @@ async function saveRecord() {
157158
}
158159
});
159160
adminforth.alert({
160-
message: 'Record created successfully',
161+
message: t('Record created successfully!'),
161162
variant: 'success'
162163
});
163164
}

adminforth/spa/src/views/ShowView.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ import { showSuccesTost, showErrorTost } from '@/composables/useFrontendApi';
120120
import ThreeDotsMenu from '@/components/ThreeDotsMenu.vue';
121121
import ShowTable from '@/components/ShowTable.vue';
122122
import adminforth from "@/adminforth";
123-
123+
import { useI18n } from 'vue-i18n';
124124
125125
const route = useRoute();
126126
const router = useRouter();
127127
const loading = ref(true);
128-
128+
const { t } = useI18n();
129129
const coreStore = useCoreStore();
130130
131131
onMounted(async () => {
@@ -179,9 +179,9 @@ const otherColumns = computed(() => {
179179
180180
async function deleteRecord(row) {
181181
const data = await adminforth.confirm({
182-
message: 'Are you sure you want to delete this item?',
183-
yes: 'Delete',
184-
no: 'Cancel',
182+
message: t('Are you sure you want to delete this item?'),
183+
yes: t('Delete'),
184+
no: t('Cancel'),
185185
});
186186
if (data) {
187187
try {
@@ -194,7 +194,7 @@ async function deleteRecord(row) {
194194
}});
195195
if (!res.error){
196196
router.push({ name: 'resource-list', params: { resourceId: route.params.resourceId } });
197-
showSuccesTost('Record deleted successfully')
197+
showSuccesTost(t('Record deleted successfully'))
198198
} else {
199199
showErrorTost(res.error)
200200
}

0 commit comments

Comments
 (0)