Skip to content

Commit a2e2b66

Browse files
authored
Merge pull request #196 from devforth/fix-translations
feat: integrate i18n for alert messages in various components
2 parents db58693 + 8925d90 commit a2e2b66

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

adminforth/spa/src/renderers/CompactUUID.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import { computed, ref, onMounted, nextTick } from 'vue';
1616
import { IconFileCopyAltSolid } from '@iconify-prerendered/vue-flowbite';
1717
import Tooltip from '@/afcl/Tooltip.vue';
1818
import adminforth from '@/adminforth';
19+
import { useI18n } from 'vue-i18n';
1920
21+
const { t } = useI18n();
2022
const visualValue = computed(() => {
2123
// if lenght is more then 8, show only first 4 and last 4 characters, ... in the middle
2224
const val = props.record[props.column.name];
@@ -33,7 +35,7 @@ const id = ref();
3335
function copyToCB() {
3436
navigator.clipboard.writeText(props.record[props.column.name]);
3537
adminforth.alert({
36-
message: 'ID copied to clipboard',
38+
message: t('ID copied to clipboard'),
3739
variant: 'success',
3840
})
3941
}

adminforth/spa/src/views/EditView.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ import { useRoute, useRouter } from 'vue-router';
8181
import { showErrorTost } from '@/composables/useFrontendApi';
8282
import ThreeDotsMenu from '@/components/ThreeDotsMenu.vue';
8383
import adminforth from '@/adminforth';
84+
import { useI18n } from 'vue-i18n';
8485
86+
const { t } = useI18n();
8587
const coreStore = useCoreStore();
8688
8789
const isValid = ref(false);
@@ -170,7 +172,7 @@ async function saveRecord() {
170172
showErrorTost(resp.error);
171173
} else {
172174
adminforth.alert({
173-
message: 'Record updated successfully',
175+
message: t('Record updated successfully'),
174176
variant: 'success',
175177
timeout: 400000
176178
});

dev-demo/custom/ApartsPie.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import { PieChart } from '@/afcl';
2929
import { callApi } from '@/utils';
3030
import adminforth from '@/adminforth';
31-
31+
import { useI18n } from 'vue-i18n';
32+
33+
const { t } = useI18n();
3234
3335
const data: Ref<any[]> = ref([]);
3436
@@ -38,7 +40,7 @@
3840
data.value = await callApi({path: '/api/aparts-by-room-percentages', method: 'GET'});
3941
} catch (error) {
4042
adminforth.alert({
41-
message: `Error fetching data: ${error.message}`,
43+
message: `${t('Error fetching data:')} ${error.message}`,
4244
variant: 'danger',
4345
timeout: 'unlimited'
4446
});

dev-demo/custom/Dash.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ onMounted(async () => {
303303
data.value = await callApi({path: '/api/dashboard/', method: 'GET'});
304304
} catch (error) {
305305
adminforth.alert({
306-
message: `Error fetching data: ${error.message}`,
306+
message: `${t('Error fetching data: ')} ${error.message}`,
307307
variant: 'danger',
308308
});
309309
}

live-demo/app/custom/Dashboard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ onMounted(async () => {
233233
data.value = await callApi({path: '/api/dashboard/', method: 'GET'});
234234
} catch (error) {
235235
adminforth.alert({
236-
message: t(`Error fetching data: {message}`, { message: error.message }),
236+
message: (t(`Error fetching data: {message}`), { message: error.message }),
237237
variant: 'danger',
238238
});
239239
}

0 commit comments

Comments
 (0)