setupI18n.js 403 B

123456789101112131415161718192021222324
  1. import {
  2. createI18n
  3. } from 'vue-i18n'
  4. import messages from './index'
  5. export let i18n;
  6. function createI18nOptions() {
  7. const locale = uni.getLocale();
  8. return {
  9. locale,
  10. messages,
  11. sync: true,
  12. silentTranslationWarn: true,
  13. missingWarn: true,
  14. silentFallbackWarn: true,
  15. };
  16. }
  17. export function setupI18n(app) {
  18. const options = createI18nOptions();
  19. i18n = createI18n(options);
  20. app.use(i18n);
  21. }