intlify / intlify/nuxt3

Cannot access custom block messages / per-component translations

Open
#74 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
204
Forks
18
PR merge metrics
No merged PRs in 30d

Description

Hiya all, we would like to use per-component translations / a custom block in our Nuxt3 project:
- We have global `/locales` already in use.
- Vue Dev Tools shows the custom block `messages` but I cannot work out how to access them.
- I logged `@intlify/vite-plugin-vue-i18n/messages` and found the `messages` defined in `/locales` but nothing from the custom block.

Please find screenshots & snippets:
- vue dev tools
![Screen Shot 2022-07-05 at 14 44 04](https://user-images.githubusercontent.com/47255988/177333417-da6c65cd-b2dc-4ecc-a8dc-c0b5b7740db3.png)

- `component.vue`
```vue

{
"en": {
"pageTitle": "Mission and Vision"
},
"de": {
"pageTitle": "Auftrag und Visionn"
}
}

import { useI18n } from 'vue-i18n'
import messages from '@intlify/vite-plugin-vue-i18n/messages'

const { t } = useI18n({
// `locale` inherit from global scope
inheritLocale: true,
})

console.log(messages)

```
![Screen Shot 2022-07-05 at 14 48 06](https://user-images.githubusercontent.com/47255988/177331507-f31197c2-4b5a-40de-955c-739064e35b6a.png)

- `nuxt.config.ts`
```js
intlify: {
localeDir: 'locales', // set the `locales` directory at source directory of your Nuxt application
vueI18n: {},
},
```

## Environment `npx nuxi info`
```
------------------------------
- Operating System: `Darwin`
- Node Version: `v16.14.0`
- Nuxt Version: `3.0.0-rc.1-27520426.ab3971d`
- Package Manager: `yarn@1.17.3`
- Builder: `vite`
- User Config: `buildModules`, `modules`, `css`, `build`, `vite`, `strapi`, `intlify`, `telemetry`
- Runtime Modules: `@intlify/nuxt3@0.2.2`, `@formkit/nuxt@1.0.0-beta.6`, `@nuxtjs/strapi@1.3.2-27565120.a6bd24b`
- Build Modules: `@vueuse/nuxt@8.3.1`
------------------------------
```

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.