Giter VIP home page Giter VIP logo

nuxt3's Introduction

@intlify/nuxt3

Nuxt3 module for vue-i18n-next

** ⚠️ IMPORTANT**

This project is maintenance mode, because I'm forcusing @nuxtjs/i18n. We would recommend to use it

❓ What is defference from @nuxtjs/i18n ?

This nuxt module is intended to be a quick and easy way for people to use vue-i18n-next with Nuxt3.

It also has the purpose of finding issues on the vue-i18n-next so that @nuxtjs/i18n can support Nuxt3.

  • Setup vue-i18n for your Nuxt3 project
    • You do not need to entrypoint codes with createI18n.
  • Setup bundle tools
    • @intlify/vue-i18n-loader and @intlify/vite-plugin-vue-i18n are included
  • Locale resources importing

💿 Installation

First install

# for npm
npm install --save-dev @intlify/nuxt3

# for yarn
yarn add -D @intlify/nuxt3

After the installation in the previous section, you need to add @intlify/nuxt3 module to modules options of nuxt.confg.[ts|js]

// nuxt.config.js
export default {
  // ...
  modules: ['@intlify/nuxt3']
  // ...
}

🔧 Configurations

You can set the following types in nuxt.config with below options:

export interface IntlifyModuleOptions {
  /**
   * Options specified for `createI18n` in vue-i18n.
   *
   * If you want to specify not only objects but also functions such as messages functions and modifiers for the option, specify the path where the option is defined.
   * The path should be relative to the Nuxt project.
   */
  vueI18n?: I18nOptions | string
  /**
   * Define the directory where your locale messages files will be placed.
   *
   * If you don't specify this option, default value is `locales`
   */
  localeDir?: string
}

The above options can be specified in the intlify config of nuxt.config

nuxt.config below:

export default {
  // ...
  modules: ['@intlify/nuxt3'],
  // config for `@intlify/nuxt3`
  intlify: {
    vueI18n: {
      // You can setting same `createI18n` options here !
      locale: 'en',
      messages: {
        en: {
          hello: 'Hello'
        },
        ja: {
          hello: 'こんにちは'
        }
      }
    }
  }
}

If you specify the path to intlify.vueI18n, you need to set it to a file in mjs format.

The following ˋnuxt.config`:

export default {
  // ...
  modules: ['@intlify/nuxt3'],
  // config for `@intlify/nuxt3`
  intlify: {
    vueI18n: 'vue-i18n.mjs'
  }
}

vue-i18n.mjs as follows:

// The configuration must be returned with an **async function**.
export default async () => ({
  locale: 'en',
  messages: {
    en: {
      hello: ({ named }) => `HELLO, ${named('name')}!`
    },
    ja: {
      hello: 'こんにちは、{name}!'
    }
  }
})

📁 Locale resources importing

You can load the locale resources stored in the file from the directory specified in intlify.localeDir.

The following is an example of the nuxt.conf:

export default {
  // ...
  modules: ['@intlify/nuxt3'],
  // config for `@intlify/nuxt3`
  intlify: {
    localeDir: 'locales', // set the `locales` directory at source directory of your Nuxt application
    vueI18n: {
      // ...
    }
  }
}

The following is a set of files of locale resources defined in the directory:

-| app/
---| nuxt.config.js
---| package.json
---| locales/
------| en.json/
------| ja.json/

The locale messages defined above will be loaded by the @intlify/nuxt3 module and set to the messages option of createI18n on the module side.

Each locale in the messages option is used as a file name without its extension. For example, In the locales directory above, en.json will use en as the locale.

©️ LICENSE

MIT

nuxt3's People

Contributors

antfu avatar atinux avatar kazupon avatar killix avatar luckywraptor avatar superbuba avatar zcube avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nuxt3's Issues

Error while mounting app: TypeError: Cannot read properties of undefined (reading 'use')

I have a trouble with setup i18n plugin :(

My package.json

{
  // ...
  "devDependencies": {
    "@intlify/nuxt3": "^0.1.10",
    "nuxt3": "latest",
    "pug": "^3.0.2",
    "pug-plain-loader": "^1.1.0",
    "stylus": "^0.55.0",
    "stylus-loader": "^6.2.0"
  },
  "dependencies": {
    "vue-i18n": "^9.2.0-beta.30"
  }
}

My nuxt.config.ts

{
  // ...
  buildModules: [
    '@intlify/nuxt3'
  ],
  intlify: {
    vueI18n: {
      locale: 'en',
      messages: {
        en: {
          hello: 'HELLO!'
        },
        ja: {
          hello: 'こんにちは!'
        }
      }
    }
  },
}

My error from console

entry.mjs?09c4:39 Error while mounting app: TypeError: Cannot read properties of undefined (reading 'use')
    at eval (plugin.mjs?f014:18:1)
    at async callWithNuxt (nuxt.mjs?73f4:87:1)
    at async applyPlugins (nuxt.mjs?73f4:55:1)
    at async initApp (entry.mjs?09c4:28:1)

Error ref to plugin.mjs, to line with app.use(i18n);

import { createI18n } from "vue-i18n";
import { defineNuxtPlugin } from "#app";
import optionsLoader from "#build/intlify.vuei18n.options.mjs";
import messages from "#build/intlify.locales.mjs";
const isEmpty = (obj) => Object.keys(obj).length === 0;
export default defineNuxtPlugin(async (nuxt) => {
  const { vueApp: app } = nuxt;
  const loadedOptions = await optionsLoader();
  if (!isEmpty(messages)) {
    loadedOptions.messages = messages;
  }
  const i18n = createI18n({
    legacy: false,
    globalInjection: true,
    locale: "en",
    ...loadedOptions
  });
  app.use(i18n);
});

This module is causing problems with Pinia installation

When I install the module I get this error: [nuxt] [request error] [🍍]: getActivePinia was called with no active...

Without the module, Nuxt & Pinia works perfect.

Tested on:

  • windows 10 and windows 11
  • nuxt 3.0.0-rc.3 and 3.0.0-rc.4

Console output:

[Vue warn]: injection "Symbol(pinia)" not found.
[Vue warn]: Unhandled error during 
execution of setup function        
  at <AppHeader>
[nuxt] [request error] [🍍]: getActivePinia was called with no active 
Pinia. Did you forget to install pinia?
        const pinia = createPinia()        app.use(pinia)
This will fail in production.      
  at Module.useStore (/C:/www/test-m580/node_modules/pinia/dist/pinia.mjs:1638:19)
  at setup (/C:/www/test-m580/.nuxt/dist/server/server.mjs:21773:45)  
  at _sfc_main.setup (/C:/www/test-m580/.nuxt/dist/server/server.mjs:21832:23)
  at callWithErrorHandling (C:\www\test-m580\node_modules\@vue\runtime-core\dist\runtime-core.cjs.js:157:22)
  at setupStatefulComponent (C:\www\test-m580\node_modules\@vue\runtime-core\dist\runtime-core.cjs.js:7084:29)
  at setupComponent (C:\www\test-m580\node_modules\@vue\runtime-core\dist\runtime-core.cjs.js:7039:11)   
  at renderComponentVNode (C:\www\test-m580\node_modules\@vue\server-renderer\dist\server-renderer.cjs.js:172:17)
  at Module.ssrRenderComponent (C:\www\test-m580\node_modules\@vue\server-renderer\dist\server-renderer.cjs.js:608:12)
  at _sfc_ssrRender (/C:/www/test-m580/.nuxt/dist/server/server.mjs:21714:31)
  at renderComponentSubTree (C:\www\test-m580\node_modules\@vue\server-renderer\dist\server-renderer.cjs.js:253:13)
[nuxt] [request error] __vite_ssr_import_2__.default is not a function  at /C:/www/test-m580/.nuxt/dist/server/server.mjs:6069:60
  at fn (/C:/www/test-m580/.nuxt/dist/server/server.mjs:433:27)       
  at Object.callAsync (/C:/www/test-m580/node_modules/unctx/dist/index.mjs:41:19)
  at callWithNuxt (/C:/www/test-m580/.nuxt/dist/server/server.mjs:435:23)
  at applyPlugin (/C:/www/test-m580/.nuxt/dist/server/server.mjs:390:29)
  at Module.applyPlugins (/C:/www/test-m580/.nuxt/dist/server/server.mjs:400:11)
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
  at async createNuxtAppServer (/C:/www/test-m580/.nuxt/dist/server/server.mjs:46:7)
  at async Object.renderToString (/C:/www/test-m580/node_modules/vue-bundle-renderer/dist/index.mjs:264:19)
  at async /C:/www/test-m580/.nuxt/dev/index.mjs:1096:20
[nuxt] [request error] __vite_ssr_import_2__.default is not a function  at /C:/www/test-m580/.nuxt/dist/server/server.mjs:6069:60
  at fn (/C:/www/test-m580/.nuxt/dist/server/server.mjs:433:27)       
  at Object.callAsync (/C:/www/test-m580/node_modules/unctx/dist/index.mjs:41:19)
  at callWithNuxt (/C:/www/test-m580/.nuxt/dist/server/server.mjs:435:23)
  at applyPlugin (/C:/www/test-m580/.nuxt/dist/server/server.mjs:390:29)
  at Module.applyPlugins (/C:/www/test-m580/.nuxt/dist/server/server.mjs:400:11)
  at processTicksAndRejections (node:internal/process/task_queues:96:5)
  at async createNuxtAppServer (/C:/www/test-m580/.nuxt/dist/server/server.mjs:46:7)
  at async Object.renderToString (/C:/www/test-m580/node_modules/vue-bundle-renderer/dist/index.mjs:264:19)
  at async /C:/www/test-m580/.nuxt/dev/index.mjs:1096:20

start error

Hi,
I've just installed "@intlify/nuxt3": "^0.1.10" with "nuxt3": "latest" and added the buildModules: ["@intlify/nuxt3"].
like this:

buildModules: ['@intlify/nuxt3'],
intlify: {
vueI18n: {
locale: 'zh',
messages: {
en: { header: {},footer:{} },
zh: { header: {},footer:{} }
}
}
}
it can work normally in the development,and it can be builded

but when i start my project ,it has error
TypeError: messageCompiler is not a function
at compileMessageFormat (file:///E:/zyf/workspace/demo-nuxt3-app/.output/server/chunks/server2.mjs:16360:15)
at translate (file:///E:/zyf/workspace/demo-nuxt3-app/.output/server/chunks/server2.mjs:16298:45)
at file:///E:/zyf/workspace/demo-nuxt3-app/.output/server/chunks/server2.mjs:16789:38
at wrapWithDeps (file:///E:/zyf/workspace/demo-nuxt3-app/.output/server/chunks/server2.mjs:16777:13)
at Proxy.t (file:///E:/zyf/workspace/demo-nuxt3-app/.output/server/chunks/server2.mjs:16789:12)
at _sfc_ssrRender$2 (file:///E:/zyf/workspace/demo-nuxt3-app/.output/server/chunks/server2.mjs:15320:242)
at renderComponentSubTree (file:///E:/zyf/workspace/demo-nuxt3-app/.output/server/chunks/index.mjs:9918:13)
at renderComponentVNode (file:///E:/zyf/workspace/demo-nuxt3-app/.output/server/chunks/index.mjs:9863:16)
at Object.ssrRenderComponent (file:///E:/zyf/workspace/demo-nuxt3-app/.output/server/chunks/index.mjs:10278:12)
at _sfc_ssrRender (file:///E:/zyf/workspace/demo-nuxt3-app/.output/server/chunks/server2.mjs:18662:32)

do you know what happened,very thx~~

Cannot start nuxt: `Cannot find module './module.json'`

Nuxt CLI v3.0.0-rc.1-27515112.2d202b5

  > Local:    http://localhost:3005/ 
  > Network:  http://10.1.1.205:3005/
  > Network:  http://10.1.0.251:3005/

 ERROR  Cannot start nuxt:  Cannot find module './module.json' 
Require stack:
- /Users/adriaan/Developer/simpleanalytics/marketing-site/node_modules/@intlify/nuxt3/dist/module.cjs

  Require stack:
  - node_modules/@intlify/nuxt3/dist/module.cjs
  at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
  at Function.resolve (internal/modules/cjs/helpers.js:98:19)
  at _resolve (node_modules/jiti/dist/jiti.js:1:192841)
  at jiti (node_modules/jiti/dist/jiti.js:1:195025)
  at node_modules/@intlify/nuxt3/dist/module.cjs:4:37
  at jiti (node_modules/jiti/dist/jiti.js:1:196506)
  at requireModule (node_modules/nuxt/node_modules/@nuxt/kit/dist/index.mjs:255:26)
  at normalizeModule (node_modules/nuxt/node_modules/@nuxt/kit/dist/index.mjs:408:53)
  at installModule (node_modules/nuxt/node_modules/@nuxt/kit/dist/index.mjs:391:47)
  at initNuxt (node_modules/nuxt/dist/index.mjs:1364:13)
{
  "devDependencies": {
    "@headlessui/vue": "^1.6.0",
    "@heroicons/vue": "^1.0.6",
    "@intlify/nuxt3": "^0.2.0",
    "@nuxtjs/tailwindcss": "^5.0.3",
    "imageoptim-cli": "^3.0.7",
    "nuxt": "npm:nuxt3@latest" // v3.0.0-rc.1-27515112.2d202b5
  }
}

Property localPath was accessed during render but is not defined on instance

When using the localPath() inside a NuxtLink like so:
<NuxtLink :to="localePath('/')">

it throws the following error:
Navbar.vue?t=1641286966884:27 Uncaught (in promise) TypeError: _ctx.localePath is not a function
at Proxy._sfc_render (Navbar.vue?t=1641286966884:27)
at renderComponentRoot (runtime-core.esm-bundler.js:464)
at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:4332)
at ReactiveEffect.run (reactivity.esm-bundler.js:160)
at setupRenderEffect (runtime-core.esm-bundler.js:4458)
at mountComponent (runtime-core.esm-bundler.js:4241)
at processComponent (runtime-core.esm-bundler.js:4199)
at patch (runtime-core.esm-bundler.js:3791)
at mountChildren (runtime-core.esm-bundler.js:3987)
at processFragment (runtime-core.esm-bundler.js:4158)

package.json:

{
  "private": true,
  "scripts": {
    "dev": "nuxi dev",
    "build": "nuxi build",
    "start": "node .output/server/index.mjs"
  },
  "dependencies": {
    "@headlessui/vue": "latest",
    "@heroicons/vue": "latest",
    "@tailwindcss/forms": "latest",
    "@types/tailwindcss": "latest",
    "autoprefixer": "^10.4.0",
    "nuxt3": "latest",
    "tailwindcss": "^3.0.7"
  },
  "devDependencies": {
    "@intlify/nuxt3": "^0.1.10"
  }
}

Cant find module in nuxt.config

Hey there.
Installed according docs but i gеting this error:

Nuxt CLI v3.0.0-rc.1

ERROR  Cannot start nuxt:  Cannot find module '@intlify/nuxt3'

I guess the problem in npm, the wrong repo is configured. Coz dir /node_modules/@intlify include only functions

Package fails on last version of Nuxt3

Hi @kazupon
The package fails on last version of Nuxt3.
Actually Nuxt updated the package std-env to version 3.0.0 a few days back and since then your package throws the following error:
import { provider, isWindows } from 'std-env';
^^^^^^^^^
SyntaxError: Named export 'isWindows' not found

You actually need to update the version of nuxt-kit in nuxt3 package package.json
Either "@nuxt/kit": "latest",
Or "@nuxt/kit": "npm:@nuxt/kit-edge@latest"

Thanks
JB

intlify: { ...; }; }' is not assignable to parameter of type 'NuxtConfig'.

When installing as described by the documentation, the follwing typescript error occurs in the nuxt.config.ts file:
intlify: { ...; }; }' is not assignable to parameter of type 'NuxtConfig'.
Object literal may only specify known properties, and 'intlify' does not exist in type 'NuxtConfig'.ts(2345)

Intlify is working despite the error, but it is important to have the types supported. How can this be achieved?

nuxt.config.ts:

import { defineNuxtConfig } from "nuxt3";

export default defineNuxtConfig({
  ...
  buildModules: [
    "@intlify/nuxt3"
  ],
  intlify: {
    vueI18n: {
      // You can setting same `createI18n` options here !
      baseUrl: "https://my.com",
      defaultLocale: "en",
      localeDir: "locales",
      locale: [
        { code: 'de', iso: 'de-DE', file: 'de-DE.json', dir: 'ltr' },
        { code: 'en', iso: 'en-US', file: 'en-US.json', dir: 'ltr' }
      ],
      strategy: "prefix_and_default",
      lazy: true,
      detectBrowserLanguage: {
        alwaysRedirect: false, 
        fallbackLocale: 'en', 
        redirectOn: 'root', 
        useCookie: true, 
        cookieCrossOrigin: false, 
        cookieDomain: null, 
        cookieKey: 'i18n_redirected', 
        cookieSecure: false
      },
      vuex: false
    },
  }
});

export interface IntlifyModuleOptions {
  /**
   * Options specified for `createI18n` in vue-i18n.
   *
   * If you want to specify not only objects but also functions such as messages functions and modifiers for the option, specify the path where the option is defined.
   * The path should be relative to the Nuxt project.
   */
  vueI18n?: I18nOptions | string
  /**
   * Define the directory where your locale messages files will be placed.
   *
   * If you don't specify this option, default value is `locales`
   */
  localeDir?: string
}

package.json:

{
  "private": true,
  "scripts": {
    "dev": "nuxi dev",
    "build": "nuxi build",
    "start": "node .output/server/index.mjs"
  },
  "devDependencies": {
    "@headlessui/vue": "latest",
    "@heroicons/vue": "latest",
    "@tailwindcss/forms": "latest",
    "@types/tailwindcss": "latest",
    "autoprefixer": "^10.4.0",
    "nuxt3": "latest",
    "tailwindcss": "^3.0.7",
    "@intlify/nuxt3": "^0.1.10"
  }
}

[Question] Does this module support route prefixes?

Does this module support route prefixes as described here in nuxt/i18n documentation.

None of these strategies work in my nuxt.config.ts

My nuxt.config.ts file.

import { defineNuxtConfig } from "nuxt";

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
  modules: ["@nuxtjs/prismic", "@intlify/nuxt3", "@nuxtjs/color-mode"],
  prismic: {
    endpoint: "https://studio-022.prismic.io/api/v2",
  },
  intlify: {
    localeDir: "locales",
    strategy: "prefix_except_default",
    vueI18n: {
      defaultLocale: "en",
      locale: "sr-latn",
      fallbackLocale: "en",
    },
  },
});

Does this feature require additional option configuration or is it not supported at all?

i18n function `$t` shows linting warning when used with more than one parameter

Describe the bug
Using i18n function $t with more than one parameter directly in a template shows linting warning. Using it in the script section works properly.

I've also opened an issue (jojomatik/nuxt-3-base#5) in my template repository for a nuxt3 project, as it is one of the blocking issues for release 1.0.0.

To Reproduce
Sourced from my template project:

 <!-- warning: Invalid number of arguments, expected 1 --> 
 <v-card-text>{{ $t("hello", { name: name }) }}</v-card-text> 

Expected behavior
No linting warning is shown.

Screenshots
image

Environment:

  • WebStorm 2022.1 EAP (Webstorm Build #WS-221.4501.160, built on February 18, 2022)
  • Version: 1.0.0-beta.3

Additional context
It is currently unclear whether this is an issue with Webstorm, vue-i18n, the linting configuration or if my template project missed an essential step of implementing vue-i18n in jojomatik/nuxt-3-base@9e4fd4b.

NuxtI18n not starting

Hi,
I've just installed "@intlify/nuxt3": "^0.1.2" with "nuxt3": "latest" and added the buildModules: ["@intlify/nuxt3"].
When I start Nuxt with npm run dev, I got an error:

(node:10922) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
Server Side Rendering Error: ./node_modules/@intlify/shared/dist/shared.esm-bundler.js:192
export { assign, createEmitter, escapeHtml, format, friendlyJSONstringify, generateCodeFrame, generateFormatCacheKey, getGlobalThis, hasOwn, inBrowser, isArray, isBoolean, isDate, isEmptyObject, isFunction, isNumber, isObject, isPlainObject, isPromise, isRegExp, isString, isSymbol, makeSymbol, mark, measure, objectToString, toDisplayString, toTypeString, warn };

I have the same problem when I copy the plugin code in plugin folder of nuxt and use vue-i18n-next

Thanks
JB

[Bug] Not working `vueI18n.locale` options

Project info:

------------------------------
- Operating System: `Windows_NT`
- Node Version:     `v17.7.2`
- Nuxt Version:     `3.0.0-27460489.53fbca7`
- Package Manager:  `[email protected]`
- Builder:          `vite`
- User Config:      `buildModules`, `intlify`
- Runtime Modules:  `-`
- Build Modules:    `@intlify/[email protected]`
------------------------------

Config:

// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
export default defineNuxtConfig({
  buildModules: ['@intlify/nuxt3'],
  intlify: {
    vueI18n: {
      localeDir: 'locales',
      vueI18n: {
        locale: 'en-US',
        fallbackLocale: 'en-US',
      }
    }
  }
})

Console log: [intlify] Not found 'meta.title' key in 'en' locale messages.

Nuxt 3 Generate - The message format compilation is not supported in this build

I am generating a static Nuxt 3 build but I am getting the following warning in my console

WARN [intlify] The message format compilation is not supported in this build. Because message compiler isn't included. You need to pre-compilation all message format. So translate function return 'message.header'.

I am using adding "@intlify/nuxt3" to nuxt modules with the intlify object and some messages.

I am rendering the translations as follows: {{ $t("mainLayout.header") }}

Any ideas what is causing this?

$tm returns a list of functions

Reporting a bug?

I'm developping a website using the release candidate version of Nuxt3 (and prior to that the beta version). To this end, I of course use @intlify/nuxt3 to integrate vue-i18n within the website. Everything is working fine, thank you for the good work you put into it, except when it comes to lists in the locales json files. I have a contact form for which I need the users to enter information, and I wanted to use i18n for the translation. When calling $tm("someKeys"), I got the following function displayed :
(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["neededTranslation"])}
I tried to call it, but it resulted in an error :
TypeError: Cannot destructure property 'normalize' of 'ctx' as it is undefined.

Expected behavior

We should get the resulted key, not a function.

Reproduction
A reproducible example in codesandbox is accessible here :
https://codesandbox.io/s/white-worker-oxsn11

Nuxt project info



devDependencies
"devDependencies": { "@intlify/nuxt3": "^0.1.10", "@nuxtjs/tailwindcss": "^5.0.0-4", "@tailwindcss/forms": "^0.5.0", "nuxt": "^3.0.0-rc.1" },
System Info

System:
OS : macOS Monterey 12.3.1 (21E258) CPU : Apple M1 Memory : 8 Go
Binaries:
Node : v16.13.2 Yarn : v1.22.17 NPM : v8.6.0
Browsers:
Safari: Version 15.4 (17613.1.17.1.13) Chrome : Version 100.0.4896.127 (official Build) (arm64)

Screenshot
Capture d’écran 2022-04-26 à 13 49 10

Additional infos
As shown in #55, the new 0.2.0 version of @intlify/nuxt3 does not work yet, so I still use 0.1.10.

Validations

localePath?

Does this support localePath and other helpers from nuxt-i18n?

Error on nuxt3 dev

Hello,

following the setup example if i run yarn dev with latest version of nuxt3 I got the following error:

ERROR  Error compiling template:  {                                                                                                                                                     11:03:25
  src: '/Users/lorenzo/SixSocksStudio/lambretta-nuxt3/node_modules/@nuxtjs/i18n/src/templates/plugin.main.js',
  fileName: 'nuxt-i18n/plugin.main.js',
  options: {
    Constants: {
      COMPONENT_OPTIONS_KEY: 'nuxtI18n',
      STRATEGIES: [Object],
      REDIRECT_ON_OPTIONS: [Object]
    },
    nuxtOptions: {
      isUniversalMode: false,
      trailingSlash: undefined
    },
    options: {
      vueI18n: {},
      vueI18nLoader: false,
      locales: [],
      defaultLocale: '',
      defaultDirection: 'ltr',
      routesNameSeparator: '___',
      defaultLocaleRouteNameSuffix: 'default',
      sortRoutes: true,
      strategy: 'prefix_except_default',
      lazy: false,
      langDir: null,
      rootRedirect: null,
      detectBrowserLanguage: [Object],
      differentDomains: false,
      baseUrl: '',
      vuex: [Object],
      parsePages: true,
      pages: {},
      skipSettingLocaleOnNavigate: false,
      onBeforeLanguageSwitch: [Function: onBeforeLanguageSwitch],
      onLanguageSwitched: [Function: onLanguageSwitched],
      normalizedLocales: [],
      localeCodes: []
    }
  },
  filename: 'nuxt-i18n/plugin.main.js',
  dst: '/Users/lorenzo/SixSocksStudio/lambretta-nuxt3/.nuxt/nuxt-i18n/plugin.main.js'
}

Thanks for supporting,
L.

Code generation from strings disallowed for this context

Trying to test with miniflare before I deploy my site to Cloudflare and I got this error:

[Vue warn]: Component  is missing template or render function.
[nuxt] [request error] Code generation from strings disallowed for this context
  at new Function (<anonymous>)  
  at messageCompiler (/home/ross/ExpidusOS/website/.nuxt/dist/server/server.mjs:5755:17)  
  at compileMessageFormat (/home/ross/ExpidusOS/website/.nuxt/dist/server/server.mjs:5856:15)  
  at translate (/home/ross/ExpidusOS/website/.nuxt/dist/server/server.mjs:5794:44)  
  at fn (/home/ross/ExpidusOS/website/.nuxt/dist/server/server.mjs:6285:38)  
  at wrapWithDeps (/home/ross/ExpidusOS/website/.nuxt/dist/server/server.mjs:6273:13)  
  at Object.t (/home/ross/ExpidusOS/website/.nuxt/dist/server/server.mjs:6285:12)  
  at Object.getWebsiteName (/home/ross/ExpidusOS/website/.nuxt/dist/server/server.mjs:7276:38)  
  at _sfc_setup$c (/home/ross/ExpidusOS/website/.nuxt/dist/server/server.mjs:8133:37)  
  at ti.setup (/home/ross/ExpidusOS/website/.nuxt/dist/server/server.mjs:8193:25)
GET / 500 Internal Server Error (132.29ms)
GET /_nuxt/entry.c2d58daf.css 200 OK (3.61ms)
GET /_nuxt/entry-dc2bc69d.mjs 200 OK (2.95ms)
GET /_nuxt/index-6f243974.mjs 200 OK (2.34ms)

Access global property of i18n instance

Hi,

is it possible to access the global property of the i18n instance for usage outside of components?
I couldn't find a way, so my current workaround is to use vue-i18n without the nuxt module and create my own plugin which exports i18n instance:

export const i18n = createI18n({
    legacy: false,
    globalInjection: true,
    locale: 'en',
    messages: {
        en,
    },
})

export default defineNuxtPlugin((nuxt) => {
    const { vueApp } = nuxt
    vueApp.use(i18n)
})

Best regards
David

[SSR] Error transforming ./node_modules/@intlify/nuxt3/dist/plugin.mjs

Environment

Operating System: macOS
Node Version: v14.17.4
Nuxt Version: 3.0.0-27246961.9d40a27
Package Manager: Yarn
Bundler: Vite
User Config: -
Runtime Modules: -
Build Modules: '@intlify/nuxt3 (0.1.4)'

Nuxt config

import nl from './lang/nl.json';
import en from './lang/en.json';

export default defineNuxtConfig({
  ...

  buildModules: ['@intlify/nuxt3'],

  intlify: {
      localeDir: 'lang',
      vueI18n: {
	      locale: 'en',
	      messages: {
		      nl,
		      en,
	      },
      },
  },

  ...
});

bug

If I start a development server (yarn dev) I run into an issue with the package missing an export.

WARN  [SSR] Error transforming ./node_modules/@intlify/nuxt3/dist/plugin.mjs: Error: Missing "./dist/plugin.mjs" export in "@intlify/nuxt3" package

Interpolations not working on production build

Interpolations not working on nuxt3 build

Declaration

{
  welcome: 'Welcome {name}!',
  hello: 'Hello',
}

Usage

<script lang="ts" setup>
import { useI18n } from 'vue-i18n'

const { t } = useI18n({ useScope: 'global' })
</script>

<template>
  <div class="p-10">
      {{ t('hello') }}
      <br />
      {{ t('welcome', { name: 'buddy' }) }}
  </div>
</template>

[Question] How can I change locale programmatically ?

Hi

as described in doc, I can change locale with $i18n.locale in component template

but I want to change it in <script setup> like this

<script setup> i18n.locale = 'en' // or locale from other resources </script>

how can I do that ?

Error: Duplicate export 'default' (Note that you need plugins to import files that are not JavaScript)

My nuxt3 templates fails to build with a new nuxt version:

PR run: https://github.com/jojomatik/nuxt-3-base/runs/5617517319?check_suite_focus=true

[log] Nuxt CLI v3.0.0-2746048[9](https://github.com/jojomatik/nuxt-3-base/runs/5617517319?check_suite_focus=true#step:7:9).53fbca7
[warn] Error when using sourcemap for reporting an error: Can't resolve original location of error.
Error:  Duplicate export 'default' (Note that you need plugins to import files that are not JavaScript)
file: virtual:/home/runner/work/nuxt-3-base/nuxt-3-base/.nuxt/intlify.vuei18n.options.mjs:3:7
1: 
2: export default () => Promise.resolve({"locale":"en","fallbackLocale":"en"})
3: export default () => Promise.resolve({"locale":"en","fallbackLocale":"en"})
          ^
Error:  Duplicate export 'default' (Note that you need plugins to import files that are not JavaScript)
  at error (node_modules/rollup/dist/shared/rollup.js:198:30)
  at Module.error (node_modules/rollup/dist/shared/rollup.js:[12](https://github.com/jojomatik/nuxt-3-base/runs/5617517319?check_suite_focus=true#step:7:12)477:[16](https://github.com/jojomatik/nuxt-3-base/runs/5617517319?check_suite_focus=true#step:7:16))
  at Module.tryParse (node_modules/rollup/dist/shared/rollup.js:12853:25)
  at Module.setSource (node_modules/rollup/dist/shared/rollup.js:12756:24)
  at ModuleLoader.addModuleSource (node_modules/rollup/dist/shared/rollup.js:222[20](https://github.com/jojomatik/nuxt-3-base/runs/5617517319?check_suite_focus=true#step:7:20):20)
Error: Process completed with exit code 1.

Works fine with previous version of nuxt3: https://github.com/jojomatik/nuxt-3-base/runs/5617504148?check_suite_focus=true

Diff: https://github.com/jojomatik/nuxt-3-base/pull/17/files

I've also tried to switch to @nuxtjs/i18n-edge as you recommended that in #44, but I could not get it working. I think it's propably a small change to switch the library, but I didn't find enought documentation unfortunately.

You are running the esm-bundler build of vue-i18n

How to get rid of this error?
You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle.

After adding `"@intlify/nuxt3"` to `buildModules` in `nuxt.config.ts` there's a Nuxt error

I installed "@intlify/nuxt3" and added it to my buildModules.

After adding "@intlify/nuxt3" to buildModules in nuxt.config.ts there's a Nuxt error:

__vite_ssr_import_2__.default is not a function

The error occurs even after reinstallation of package and after removing .nuxt directory.

Stacktrace:

at ./.nuxt/dist/server/server.mjs:3590:60
at fn (./.nuxt/dist/server/server.mjs:396:27)
at Object.callAsync (./node_modules/unctx/dist/index.mjs:41:19)
at callWithNuxt (./.nuxt/dist/server/server.mjs:398:23)
at applyPlugin (./.nuxt/dist/server/server.mjs:353:29)
at Module.applyPlugins (./.nuxt/dist/server/server.mjs:363:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async createNuxtAppServer (./.nuxt/dist/server/server.mjs:46:7)
at async renderToString (./node_modules/vue-bundle-renderer/dist/index.mjs:252:19)
at async ./.nuxt/dev/index.mjs:486:20

The line that shows an error is this one:

const loadedOptions = await __vite_ssr_import_2__.default();

This line is in a code block:

const { vueApp: app } = nuxt;
  const loadedOptions = await __vite_ssr_import_2__.default();
  if (!isEmpty(__vite_ssr_import_3__.default)) {
    loadedOptions.messages = __vite_ssr_import_3__.default;
  }
  const i18n = __vite_ssr_import_0__.createI18n({
    legacy: false,
    globalInjection: true,
    locale: "en",
    ...loadedOptions
  });
  app.use(i18n);

[plugin:vite-plugin-vue-i18n] Cannot read property 'message' of undefined

Hello, using latest version of nuxt and @intlify/nuxt3, having this nuxt config

  intlify: {
    localeDir: 'locales', // set the `locales` directory at source directory of your Nuxt application
    vueI18n: {
      legacy: false,
      locale: 'en',
      fallbackLocale: 'en',
      globalInjection: true,
    },
  },

Info:

------------------------------
- Operating System: `Darwin`
- Node Version:     `v14.17.0`
- Nuxt Version:     `3.0.0-27277498.850ef69`
- Package Manager:  `[email protected]`
- Bundler:          `Vite`
- User Config:      `target`, `head`, `css`, `loading`, `publicRuntimeConfig`, `plugins`, `components`, `buildModules`, `modules`, `intlify`, `pwa`, `sanity`, `gtm`, `sitemap`, `robots`
- Runtime Modules:  `@nuxtjs/[email protected]`
- Build Modules:    `[email protected]`, `@intlify/[email protected]`
------------------------------

and a folder locales with a file called it.json and en.json I got the following error:

[plugin:vite-plugin-vue-i18n] Cannot read property 'message' of undefined
/Users/lorenzo/secretproject/locales/it.json
    at Object.newOptions.onError (/Users/lorenzo/secretproject/node_modules/@intlify/bundle-utils/lib/codegen.js:102:48)
    at Object.newOptions.onError (/Users/lorenzo/secretproject/node_modules/@intlify/bundle-utils/lib/codegen.js:102:36)
    at newOptions.onError (/Users/lorenzo/secretproject/node_modules/@intlify/bundle-utils/lib/codegen.js:102:36)
    at emitError (/Users/lorenzo/secretproject/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:845:13)
    at parseLinked (/Users/lorenzo/secretproject/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:979:17)
    at parseMessage (/Users/lorenzo/secretproject/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:1036:36)
    at parseResource (/Users/lorenzo/secretproject/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:1075:25)
    at Object.parse (/Users/lorenzo/secretproject/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:1090:21)
    at Object.baseCompile (/Users/lorenzo/secretproject/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:1402:24)
    at Object.generateMessageFunction (/Users/lorenzo/secretproject/node_modules/@in

Of course I am not seeing translated content if I dismiss the error.

Thanks for help,
L.

$t not accessible

I have configured the package and I get this error
Property "$t" was accessed during render but is not defined on the instance.

don't know what I am missing

Not found 'some.key' key in locale messages, when it's a message function

Reporting a bug?

With a message function, even just a trivial one like:

'someKey': () => 'foo',

intlify errors that the key could not be found; if it is converted to a plain string 'someKey': 'foo' it works fine.

Expected behavior

Key should be found and translated to its value function's return value.

Reproduction

<p>{{ $t('someKey') }}</p>
{
  someKey: () => 'someVal',
}

System Info

System:
    OS: Linux 5.16 Arch Linux
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 4.03 GB / 31.08 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 17.6.0 - /usr/bin/node
    Yarn: 1.22.17 - /usr/bin/yarn
    npm: 8.5.2 - /usr/bin/npm
  Browsers:
    Firefox: 97.0.1
  npmPackages:
    @intlify/nuxt3: ^0.1.10 => 0.1.10
    @vue/test-utils: ^2.0.0-rc.18 => 2.0.0-rc.18
    @vue/vue3-jest: ^27.0.0-alpha.4 => 27.0.0-alpha.4
    vue-chart-3: ^3.1.0 => 3.1.2
    vue-i18n: 9 => 9.1.9

Screenshot

No response

Additional context

No response

Validations

node 17 compatible

Hi! Can you release new version with node 17? Patch already exists #28 , need only new version on npm

message.replace error

I get errors when trying to run your package in dev mode.

The error:

message.replace is not a function
at format (file://./.nuxt/dist/server/server.mjs:4374:20)
at evaluateMessage (file://./.nuxt/dist/server/server.mjs:5160:22)
at Module.translate (file://./.nuxt/dist/server/server.mjs:4992:22)
at file://./.nuxt/dist/server/server.mjs:2458:62
at wrapWithDeps (file://./.nuxt/dist/server/server.mjs:2408:23)
at t (file://./.nuxt/dist/server/server.mjs:2458:16)
at setup (file://./.nuxt/dist/server/server.mjs:2034:17)
at _sfc_main.setup (file://./.nuxt/dist/server/server.mjs:2050:23)
at callWithErrorHandling (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:6615:22)
at setupStatefulComponent (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:6241:29)

I've done my research and debugged your code and it seems like VITE might be the problem here and not the Nuxt 3 itself. Any plans to fix this issue soon?

Maybe Nuxt 3 is too soon to begin to actually use in real production-ready projects.

messageCompiler is not a function on build. how to set runtimeOnly: false?

readme at https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n states that for build you need to set the runtimeOnly option to false.

but how to set it in Nuxt3? build fails with messageCompiler is not a function

such things don't work:

export default defineNuxtConfig({
    buildModules: ['@intlify/nuxt3'],
    vite: {
        resolve: {
            alias: {
                'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js'
            }
        }
    },
    alias: {
        'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js'
    },

(in fact these options are completely ignored because setting there non-existent files doesn't break build)

UPD
looking at callstack, it is error in compileMessageFormat func, that is part of @intlify/core-base

aliasing it also doesn't work:

vite: {
        resolve: {
            alias: {
                '@intlify/core-base': '@intlify/core-base/dist/core-base.esm-bundler.js'
            }
        }
    },
    alias: {
        '@intlify/core-base': '@intlify/core-base/dist/core-base.esm-bundler.js'
    },

Inputs' dynamic attributes are translated in dev and SSR but not in SSG

I'm using @intlify/nuxt3 to internationalize a website. I build and deployed the site in ssr: true and target: server (default) and hosted it on vercel and It works good in dev, preview and production.

Now I'm trying to build the app with SSG (ssr: true and target: static) using the following steps:

  • Added target: static to the nuxt.config.ts
  • Runned nuxt generate instead of nuxt build

The complete app is translated correctly in dev upon choosing a locale. However, after running nuxt generate and nuxt preview, the app is almost completely translated except of buttons having dynamic placeholder and aria-label atrributes.

my component snippet:

<form>
  <input
    type="number"
    name="flight-no"
    :aria-label="$t('sections.flight_request.form.flight_no')"
    :placeholder="$t('sections.flight_request.form.flight_no')"
  />

  <input
    type="text"
    name="full-name"
    :aria-label="$t('sections.flight_request.form.full_name')"
    :placeholder="$t('sections.flight_request.form.full_name')"
  />
</form>

The project repo on GitHub: https://github.com/MuhammadM1998/EGSA

How to use localePath() in middleware

export default defineNuxtRouteMiddleware((to, from) => {
  const nuxtApp = useNuxtApp()
  const locales = nuxtApp.vueApp.i18n.availableLocales // locales localeCodes
  const isLocalised = locales.some(locale => to.fullPath.startsWith('/' + locale))
  
  if (!isLocalised) {
    return navigateTo(localePath(to))
  }
}

or how to get fallback locale?

messageCompiler is not a function

Hi team i'm getting this problem in production mode

import { enUS, viVN } from './locales'

  intlify: {
    localeDir: 'locales',
    vueI18n: {
      locale: 'en-US',
      messages: {
        'en-US': {
          ...enUS
        },
      },
    },
  },

locales/enUS.ts

  'page.global.table.favorites': 'Favorites',
  'page.global.table.status': 'Status',
  'page.global.table.name': 'Name',
  'page.global.table.date': 'Date',
  'page.global.table.time': 'Time',
  'page.global.table.pair': 'Pair',
  'page.global.table.coin': 'Coin',
  'page.global.table.currency': 'Currency',
  'page.global.table.infomation': 'Infomation',
  'page.global.table.last_price': 'Last Price',
  'page.global.table.price': 'Price',
  'page.global.table.market': 'Market',
  'page.global.table.change': 'Change',
  'page.global.table.volume': 'Volume',
  'page.global.table.sum': 'Sum',
  'page.global.table.amount': 'Amount',

Thanks for your help

Accept-Language header

Is there a way to check the Accept-Language and set the i18n locale based on it? It would make embedding metadata better.

Path setting not mapped

export default {
// ...
buildModules: ['@intlify/nuxt3'],
// config for @intlify/nuxt3
intlify: {
vueI18n: 'vue-i18n.mjs'
}
}

vue-i18n.mjs

// The configuration must be returned with an async function.
export default async () => ({
locale: 'en',
messages: {
en: {
hello: 'hellotest'
},
ja: {
hello: 'こんにちは、{name}!'
}
}
})

index.vue

import { useI18n } from 'vue-i18n'

{{ t("hello") }}

const { t, te } = useI18n();

Returns hello as a string.

Also, how can I change to another language if I already use en?

For example, I want to convert by selecting a language in the select box.

Do you have a guide on this?

Cannot access custom block messages / per-component translations

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:  `[email protected]`
- Builder:          `vite`
- User Config:      `buildModules`, `modules`, `css`, `build`, `vite`, `strapi`, `intlify`, `telemetry`
- Runtime Modules:  `@intlify/[email protected]`, `@formkit/[email protected]`, `@nuxtjs/[email protected]`
- Build Modules:    `@vueuse/[email protected]`
------------------------------

build error

Reproduce

just build

environment

window10 21H2
node v16.14.0
@intlify/[email protected]
nuxt3@latest: 3.0.0-27356801.e9128f3

terminal log out:

$ nuxi build
Nuxt CLI v3.0.0-27356801.e9128f3 17:10:57

WARN Error when using sourcemap for reporting an error: Can't resolve original location of error. 17:11:03

ERROR 'handleFlatJson' is not exported by node_modules@intlify\nuxt3\node_modules@intlify\core-base\dist\core-base.esm-bundler.js, imported by node_modules\vue-i18n\dist\vue-i18n.runtime.esm-bundler.js
file: E:/nut/node_modules/vue-i18n/dist/vue-i18n.runtime.esm-bundler.js:7:29
5: */
6: import { getGlobalThis, format, makeSymbol, isPlainObject, isArray, hasOwn, isObject, isBoolean, isString, isRegExp, isFunction, assign, isNumber, warn, createEmitter, isEmptyObject } from '@intlify/shared';
7: import { createCompileError, handleFlatJson, createCoreContext, updateFallbackLocale, resolveValue, clearDateTimeFormat, clearNumberFormat, setAdditionalMeta, NOT_REOSLVED, isTranslateFallbackWarn, isTranslateMissingWarn, parseTranslateArgs, translate, MISSING_RESOLVE_VALUE, parseDateTimeArgs, datetime, parseNumberArgs, number, getLocaleChain, setDevToolsHook } from '@intlify/core-base';
^
8: import { ref, getCurrentInstance, computed, watch, createVNode, Text, h, Fragment, inject, onMounted, onUnmounted, isRef } from 'vue';
9: import { setupDevtoolsPlugin } from '@vue/devtools-api';

ERROR 'handleFlatJson' is not exported by node_modules@intlify\nuxt3\node_modules@intlify\core-base\dist\core-base.esm-bundler.js, imported by node_modules\vue-i18n\dist\vue-i18n.runtime.esm-bundler.js

at error (node_modules\rollup\dist\shared\rollup.js:158:30)
at Module.error (node_modules\rollup\dist\shared\rollup.js:12423:16)
at Module.traceVariable (node_modules\rollup\dist\shared\rollup.js:12808:29)
at ModuleScope.findVariable (node_modules\rollup\dist\shared\rollup.js:11588:39)
at FunctionScope.findVariable (node_modules\rollup\dist\shared\rollup.js:6953:38)
at ChildScope.findVariable (node_modules\rollup\dist\shared\rollup.js:6953:38)
at TrackingScope.findVariable (node_modules\rollup\dist\shared\rollup.js:6953:38)
at BlockScope.findVariable (node_modules\rollup\dist\shared\rollup.js:6953:38)
at BlockScope.findVariable (node_modules\rollup\dist\shared\rollup.js:6953:38)
at BlockScope.findVariable (node_modules\rollup\dist\shared\rollup.js:6953:38)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Installation breaks nuxt dev

hi, I'm getting this error on windows, after installing "@intlify/nuxt3": "^0.1.8" package

I tried on a fresh project on Stackblitz, and there is no problem there.

I'm running windows 11 Version 21H2, Node v14.17.3, and getting the errors with the same setup that Stackblitz

 WARN  [worker] Named export 'provider' not found. The requested module 'std-env' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'std-env';
const { provider, isWindows } = pkg;


  import { provider, isWindows } from 'std-env';
  ^^^^^^^^
  SyntaxError: Named export 'provider' not found. The requested module 'std-env' is a CommonJS module, which may not support all module.exports as named exports.
  CommonJS modules can always be imported via the default export, for example using:

  import pkg from 'std-env';
  const { provider, isWindows } = pkg;

  at ModuleJob._instantiate (internal/modules/esm/module_job.js:120:21)
  at async ModuleJob.run (internal/modules/esm/module_job.js:165:5)
  at async Loader.import (internal/modules/esm/loader.js:177:24)
  at async Object.loadESM (internal/process/esm_loader.js:68:5)

Thanks for the amazing work.

__vite_ssr_import_2__.default is not a function

I created an empty Nuxt project
npx nuxi init nuxt-app

then I added a intlify/nuxt3
yarn add -D @intlify/nuxt3

// nuxt.config.ts

import { defineNuxtConfig } from 'nuxt'

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
    buildModules: ['@intlify/nuxt3'],
    // config for `@intlify/nuxt3`
    intlify: {
        vueI18n: {
            // You can setting same `createI18n` options here !
            locale: 'en',
            messages: {
                en: {
                    hello: 'Hello'
                },
                ja: {
                    hello: 'こんにちは'
                }
            }
        }
    }
})

and i get an error
__vite_ssr_import_2__.default is not a function

at /D:/work/nuxt-app/.nuxt/dist/server/server.mjs:10636:60
at fn (/D:/work/nuxt-app/.nuxt/dist/server/server.mjs:412:27)
at Object.callAsync (/D:/work/nuxt-app/node_modules/unctx/dist/index.mjs:41:19)
at callWithNuxt (/D:/work/nuxt-app/.nuxt/dist/server/server.mjs:414:23)
at applyPlugin (/D:/work/nuxt-app/.nuxt/dist/server/server.mjs:369:29)
at Module.applyPlugins (/D:/work/nuxt-app/.nuxt/dist/server/server.mjs:379:11)
at async createNuxtAppServer (/D:/work/nuxt-app/.nuxt/dist/server/server.mjs:46:7)
at async Object.renderToString (/D:/work/nuxt-app/node_modules/vue-bundle-renderer/dist/index.mjs:252:19)
at async /D:/work/nuxt-app/.nuxt/dev/index.mjs:465:20
at async /D:/work/nuxt-app/node_modules/h3/dist/index.mjs:417:19

my package.json

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview"
  },
  "devDependencies": {
    "@intlify/nuxt3": "^0.2.2",
    "nuxt": "3.0.0-rc.3"
  }
}

SSR not works

Hi,
i have installed "@intlify/nuxt3": "^0.1.8" and "nuxt3": "latest". When i build app with NITRO_PRESET=server npx nuxt build and run it with node .output/server/index.mjs, i get error in browser and app is not work.

Uncaught (in promise) TypeError: Cannot convert undefined or null to object
at Function.getOwnPropertyDescriptor ()
at entry-980309c8.mjs:25
at Array.forEach ()
at am (entry-980309c8.mjs:25)
at Object.install (entry-980309c8.mjs:25)
at Object.use (entry-980309c8.mjs:1)
at entry-980309c8.mjs:25
at async hf (entry-980309c8.mjs:1)
at async uf (entry-980309c8.mjs:1)
at async va (entry-980309c8.mjs:25)

The app is here https://github.com/kozderka/nuxt3-test

Thanks
Michal

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.