Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEXT] Could not find de locale in localeMessages #1610

Closed
juni0r opened this issue Nov 4, 2022 · 4 comments
Closed

[NEXT] Could not find de locale in localeMessages #1610

juni0r opened this issue Nov 4, 2022 · 4 comments

Comments

@juni0r
Copy link

juni0r commented Nov 4, 2022

Version

@nuxtjs/i18n: 8.0.0-beta.3
nuxt: 3.0.0-rc.12

Nuxt configuration

import numberFormats from "./locales/numberFormats";

export default defineNuxtConfig({
  modules: ["@nuxt/content", "@nuxtjs/i18n"],
  content: {
    documentDriven: true,
  },
  i18n: {
    vueI18n: {
      fallbackLocale: "de",
      numberFormats,
    },
    locales: [{ code: "de", iso: "de-DE", file: "de.js" }],
    defaultLocale: "de",
    langDir: "~/locales/",
  },
});

Reproduction Link

https://github.com/juni0r/nuxi18n

What is Expected?

Locale file for 'de' is loaded from ~/locales/de.js

What is actually happening?

[@nuxtjs/i18n] Could not find de locale in localeMessages
[intlify] Not found 'amount' key in 'de' locale messages.
@juni0r juni0r added the bug 🐛 label Nov 4, 2022
@mateusk
Copy link

mateusk commented Nov 4, 2022

Same here. I am on Nuxt 3.0.0-rc.12 and @nuxtjs/i18n-edge. I had to move my /locales folder from /src to the app root folder, only then are the locale files correctly loaded again.

@kazupon kazupon added the v8 label Nov 5, 2022 — with Volta.net
Copy link
Collaborator

kazupon commented Nov 5, 2022

Thank you for your reporting!

locales: [{ code: "de", iso: "de-DE", file: "de.js" }],

You need to use JSON format as locale resources, not JavaScript executable format.
(Currently support JSON, JSON5 and YAML)
https://v8.i18n.nuxtjs.org/guide/lazy-load-translations

langDir: "~/locales/",

you need to specify relative path from nuxt app project on langDir options. (e.g ./locales).

@kazupon kazupon closed this as completed Nov 5, 2022
@joffreyBerrier
Copy link

Hi @kazupon, why you only use JSON, JSON5 and YAML and not Javascript? Today my nuxt@2 project works with the same library.
I have separated all my translation files so I can't import them into a JSON file. Do you see the problem? 🥺

Example :

import { View1 } from "@/pages/views1/lang/fr";
import { View2 } from "@/pages/views2/lang/fr";
import { View3 } from "@/pages/views3/lang/fr";

export default {
  lang: "fr",
  ...views1,
  ...views2,
  ...views3
}

Copy link
Collaborator

kazupon commented Nov 30, 2022

I'm working on js/ts supporting.
please wait.
see details #1576 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants