intlify / nuxt3

Nuxt 3 Module for vue-i18n-next

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot access custom block messages / per-component translations

MoodyBones opened this issue · comments

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

  • component.vue

<i18n>
{
  "en": {
    "pageTitle": "Mission and Vision"
  },
  "de": {
    "pageTitle": "Auftrag und Visionn"
  }
}
</i18n>

<script setup>
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)
</script>

Screen Shot 2022-07-05 at 14 48 06

  • nuxt.config.ts
  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`
------------------------------

Duplicate: #84