Closed Sunny-liaokai closed 1 year ago
@Sunny-liaokai use this config
import type { App } from 'vue';
import { createI18n } from 'vue-i18n';
import messages from '@intlify/unplugin-vue-i18n/messages';
export const I18n = createI18n({
locale: 'en',
messages,
globalInjection: true,
legacy: false,
});
export default (app: App) => {
app.use(I18n);
};
vite: {
plugins: [
VueI18nPlugin({
include: ['./src/i18n/**'],
}),
],
resolve: {
alias: [
{
find: 'vue-i18n',
replacement: 'vue-i18n/dist/vue-i18n.cjs.js',
},
],
},
},
IIUC appEntrypoint
is used for both SSR and the client, so you can't use window
, navigator
, etc there. You'd need a fallback language on SSR to work, especially for static builds. For output: 'server'
, you could derive the language from req.headers["accept-language"]
, which the req
could be from Astro.request
.
What version of
astro
are you using?2.3.2
Are you using an SSR adapter? If so, which one?
no
What package manager are you using?
npm
What operating system are you using?
windows
What browser are you using?
chrome
Describe the Bug
After importing vue and specifying the vue App entry file in astro.config.mjs Problems encountered in registering vue-il8n in the entry file. I want to obtain the local browser language through the browser, but the Windows object is empty.
Link to Minimal Reproducible Example
1
Participation