Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIte + Vue2 example #1597

Open
3 tasks done
montella1507 opened this issue Nov 30, 2022 · 2 comments
Open
3 tasks done

VIte + Vue2 example #1597

montella1507 opened this issue Nov 30, 2022 · 2 comments
Labels
Status: Proposal Request for comments

Comments

@montella1507
Copy link

Clear and concise description of the problem

Please provide example of Vite + Vue2 solution, there is no way how to make this work :-/

Suggested solution

Small example with vite.config.js, tsconfig.base.json and 2 types of messages:

  • global
  • local in blocks

Alternative

No response

Additional context

No response

Validations

@montella1507 montella1507 added the Status: Proposal Request for comments label Nov 30, 2022
@LDY681
Copy link

LDY681 commented Dec 26, 2022

Simply switch Webpack's module.hot() to Vite's import.meta.hot().
I wish they should provide it in the docs too.
Here is a simple snippet for you :)

import Vue from 'vue'
import VueI18n from 'vue-i18n'
import en from "@/locales/en.json";
import zhHans from "@/locales/zhHans.json";
import zhHant from "@/locales/zhHant.json";

Vue.use(VueI18n);

const messages = {
  en,
  zhHans,
  zhHant
}

const i18n = new VueI18n({
  locale: 'en',
  messages
})

// Hot updates
if (import.meta.hot) {
  import.meta.hot.on("locales-update", (data) => {
    i18n.setLocaleMessage('en', en.default)
    i18n.setLocaleMessage('zhHans', zhHans.default)
    i18n.setLocaleMessage('zhHant', zhHant.default)
  })
}
export default i18n;

@meiliujun
Copy link

how to use Lazy loading translations in vite + vue2 .
8.x not provide an example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Proposal Request for comments
Projects
None yet
Development

No branches or pull requests

3 participants