Skip to content

Outdated @intlify/vite-plugin-vue-i18n causes issue with JSON #15388

Open
@BernhardSchlegel

Description

@BernhardSchlegel

What happened?

Currently migrating my old v1 project to v2 by starting with a vanilla one. Added my i18n JSONs. Received an error

[plugin:vite-plugin-vue-i18n] Cannot read properties of undefined (reading 'message')
/home/bernhard/wd/quasar2-project/src/i18n/en-US.json

What did you expect to happen?

Reading JSON as expected.

Reproduction URL

https://codepen.io/BernhardSchlegel/pen/GRBeYyb

How to reproduce?

Setup a new project. Use the following files

// boot/i18n.ts

import { boot } from 'quasar/wrappers';
import { createI18n } from 'vue-i18n';

import messages from 'src/i18n';

export type MessageLanguages = keyof typeof messages;
// Type-define 'en-US' as the master schema for the resource
export type MessageSchema = typeof messages['en-US'];

// See https://vue-i18n.intlify.dev/guide/advanced/typescript.html#global-resource-schema-type-definition
/* eslint-disable @typescript-eslint/no-empty-interface */
declare module 'vue-i18n' {
  // define the locale messages schema
  export interface DefineLocaleMessage extends MessageSchema {}

  // define the datetime format schema
  export interface DefineDateTimeFormat {}

  // define the number format schema
  export interface DefineNumberFormat {}
}
/* eslint-enable @typescript-eslint/no-empty-interface */

export default boot(({ app }) => {
  const i18n = createI18n({
    locale: 'en-US',
    legacy: false,
    messages : messages
  });

  // Set i18n instance on app
  app.use(i18n);
});
// i18n/index.ts
import enUSMain from "./en-us.json"

const enUS = Object.assign({}, enUSMain); //

export default {
  "en-US": enUS,
};

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite)

Platforms/Browsers

No response

Quasar info output

How to solve: By default, quasar is using `"@intlify/vite-plugin-vue-i18n": "^3.3.1"`. Changing that to `"@intlify/vite-plugin-vue-i18n": "^7.0.0"` solved the issue.

Relevant log output

No response

Additional context

Already solved, see above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions