Skip to content

Commit 696f7fc

Browse files
committed
perf: remove petite-i18n-vue footprint in frontend app
It was causing reload
1 parent 4769d56 commit 696f7fc

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

locals/locales/src/composer.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { ComposerOptions } from 'petite-vue-i18n'
2+
import { createI18n } from 'petite-vue-i18n'
3+
import { unref } from 'vue'
4+
5+
/**
6+
* Clones a composer instance, similar to creating a "local scope", so that you can change the locale without affecting the global/original instance and do translations of many locales in parallel
7+
*/
8+
export function cloneComposer<C>(composer: C): C {
9+
const options = {} as ComposerOptions
10+
11+
for (const key in composer) {
12+
if (key.startsWith('_'))
13+
continue
14+
15+
// @ts-expect-error index signature blah blah
16+
options[key] = unref(composer[key])
17+
}
18+
19+
return createI18n(options).global as any as C
20+
}

locals/locales/src/index.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
/**
2-
* @module @local/locales/index
3-
* @description this module contains reusable default i18n options/configuration and some helper goodies
4-
*/
5-
61
import type { ComposerOptions } from 'petite-vue-i18n'
7-
import { createI18n } from 'petite-vue-i18n'
8-
import { unref } from 'vue'
92

103
export const defaultOptions = {
114
legacy: false,
@@ -14,20 +7,3 @@ export const defaultOptions = {
147
fallbackWarn: false,
158
missingWarn: false,
169
} satisfies ComposerOptions & { legacy: false }
17-
18-
/**
19-
* Clones a composer instance, similar to creating a "local scope", so that you can change the locale without affecting the global/original instance and do translations of many locales in parallel
20-
*/
21-
export function cloneComposer<C>(composer: C): C {
22-
const options = {} as ComposerOptions
23-
24-
for (const key in composer) {
25-
if (key.startsWith('_'))
26-
continue
27-
28-
// @ts-expect-error index signature blah blah
29-
options[key] = unref(composer[key])
30-
}
31-
32-
return createI18n(options).global as any as C
33-
}

0 commit comments

Comments
 (0)