Skip to content

Commit 6c66d27

Browse files
committed
Revert "fix: use useI18n instead of window.i18n"
This reverts commit 2a2b20b.
1 parent 2a2b20b commit 6c66d27

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

adminforth/spa/src/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ import { createPinia } from 'pinia'
55

66
import App from './App.vue'
77
import router from './router'
8+
import { initI18n } from './i18n'
89

910
export const app: ReturnType<typeof createApp> = createApp(App)
1011
/* IMPORTANT:ADMINFORTH COMPONENT REGISTRATIONS */
1112

1213
app.use(createPinia())
1314
app.use(router)
1415

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

1620
/* IMPORTANT:ADMINFORTH CUSTOM USES */
1721

adminforth/spa/src/utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ import adminforth from './adminforth';
99
import sanitizeHtml from 'sanitize-html'
1010
import debounce from 'debounce';
1111
import type { AdminForthResourceColumnInputCommon, Predicate } from '@/types/Common';
12-
import { useI18n } from 'vue-i18n';
1312

1413
const LS_LANG_KEY = `afLanguage`;
1514
const MAX_CONSECUTIVE_EMPTY_RESULTS = 2;
1615
const ITEMS_PER_PAGE_LIMIT = 100;
17-
const { t } = useI18n();
1816

1917
export async function callApi({path, method, body, headers}: {
2018
path: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'
@@ -44,11 +42,11 @@ export async function callApi({path, method, body, headers}: {
4442
// if it is internal error, say to user
4543
if (e instanceof TypeError && e.message === 'Failed to fetch') {
4644
// this is a network error
47-
adminforth.alert({variant:'danger', message: t('Network error, please check your Internet connection and try again'),})
45+
adminforth.alert({variant:'danger', message: window.i18n?.global?.t('Network error, please check your Internet connection and try again'),})
4846
return null;
4947
}
5048

51-
adminforth.alert({variant:'danger', message: t('Something went wrong, please try again later'),})
49+
adminforth.alert({variant:'danger', message: window.i18n?.global?.t('Something went wrong, please try again later'),})
5250
console.error(`error in callApi ${path}`, e);
5351
}
5452
}

0 commit comments

Comments
 (0)