intlify / intlify/bundle-tools

vite-plugin-vue-i18n custom block messages aren't loaded

Open
#120 11 comments 6 reactions 0 assignees View on GitHub
status: review needed
Dominant language
TypeScript
Stars
270
Forks
46
PR merge metrics
No merged PRs in 30d

Description

### Reporting a bug?

Hi guys,

I have been using custom blocks in sfc for a while.

I migrated from Vue 2 to 3 and Vue i18n from v8 to 9. I used vue cli and vue i18n loader for the custom block. Since the migration, i now use vue 3 + Vue i18n v9 + vite vite-plugin-vue-i18n.

I want to use the legacy api for i18n to minimize the page migration work. However, $t only picks up the global resources loaded from vite.config and my i18n setting below

```
export default defineConfig({
plugins: [
vue(),
vueI18n({
// if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
compositionOnly: false,
include: resolve(__dirname, "./src/locales/**"),
}),
],
});
```

```
import { createI18n } from "vue-i18n";
import messages from "@intlify/vite-plugin-vue-i18n/messages";

const i18n = createI18n({
legacy: true, // you must set `false`, to use Composition API
locale: 'en-US',
fallbackLocale: 'en-US',
messages,
});
```

The custom block doesnt seem to be loaded into the instance for some reason.

Is it a bug or not supported or I missed something?

### Expected behavior

custom block messages should be loaded

### Reproduction

see description above

### Issue Package

vite-plugin-vue-i18n

### System Info

```shell
System:
OS: Windows 10 10.0.22598
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Memory: 10.05 GB / 31.71 GB
Binaries:
Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
npm: 8.5.5 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22598.200.0), Chromium (101.0.1210.39)
Internet Explorer: 11.0.22598.1
```

### Screenshot

_No response_

### Additional context

_No response_

### Validations

- [X] Read the [Contributing Guidelines](https://github.com/intlify/bundle-tools/blob/main/.github/contributing.md).
- [X] Read the README
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/intlify/bundle-tools/discussions).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.