Skip to content

Commit 028a0ef

Browse files
committed
update:added translation to alert message
1 parent be9f6c9 commit 028a0ef

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

adminforth/spa/src/i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ export function initI18n(app: ReturnType<typeof createApp>) {
5151
})
5252

5353
app.use(i18n);
54-
54+
return i18n
5555
}

adminforth/spa/src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export const app: ReturnType<typeof createApp> = createApp(App)
1313
app.use(createPinia())
1414
app.use(router)
1515

16-
initI18n(app);
16+
// get access to i18n instance outside components
17+
window.i18n = initI18n(app);
1718

1819

1920
/* IMPORTANT:ADMINFORTH CUSTOM USES */

adminforth/spa/src/utils.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { onMounted, ref, resolveComponent } from 'vue';
22
import type { CoreConfig } from './spa_types/core';
33
import type { ValidationObject } from './types/AdminForthConfig';
4-
5-
64
import router from "./router";
75
import { useCoreStore } from './stores/core';
86
import { useUserStore } from './stores/user';
97
import { Dropdown } from 'flowbite';
108

9+
1110
const LS_LANG_KEY = `afLanguage`;
1211

1312
export async function callApi({path, method, body=undefined}: {
@@ -32,10 +31,9 @@ export async function callApi({path, method, body=undefined}: {
3231
}
3332
return await r.json();
3433
} catch(e){
35-
window.adminforth.alert({variant:'danger', message:'Something went wrong, please try again later',})
36-
console.error('error',e);
34+
window.adminforth.alert({variant:'danger', message:window.i18n?.global?.t('Something went wrong, please try again later'),})
35+
console.error(`error in callApi ${path}`,e);
3736
}
38-
3937
}
4038

4139
export async function callAdminForthApi({ path, method, body=undefined, headers=undefined }: {

0 commit comments

Comments
 (0)