yassinedoghri / astro-i18next

An astro integration of i18next + some utility components to help you translate your astro websites!
https://astro-i18next.yassinedoghri.com
MIT License
521 stars 37 forks source link

Disable 'missing translation key' for default locale when using text as keys #164

Open paulathevalley opened 1 year ago

paulathevalley commented 1 year ago

Is your feature request related to a problem? Please describe.

When using text as keys for the default locale, this particular log to the console becomes very noisy: https://github.com/yassinedoghri/astro-i18next/blob/beta/src/utils.ts#L59-L62

// astro-i18next.config.ts
import type { AstroI18nextConfig } from "astro-i18next";

const config: AstroI18nextConfig = {
  defaultLocale: "en",
  locales: ["en", "es"],
  i18nextServer: {
    debug: true,
    // Set key as fallback https://www.i18next.com/principles/fallback#key-fallback
    fallbackLng: false,
    backend: {
      loadPath: "./public/locales/{{lng}}/{{ns}}.json",
      addPath: "./public/locales/{{lng}}/{{ns}}.missing.json",
    },
    saveMissing: true
  },
};

export default config;

public/locales/en/translation.json

{ 
  "Hello": "Hello",
  "Search": "Search"
}

public/locales/es/translation.json

{
  "Hello": "Hola",
  "Search": "Buscar"
}

console:

WARNING(astro-i18next): missing translation key Hello
WARNING(astro-i18next): missing translation key Search

Describe the solution you'd like

Is it possible to disable the WARNING(astro-i18next): missing translation key logging for the default locale?

Describe alternatives you've considered

Related issues: https://github.com/i18next/i18next/issues/1634#issuecomment-907651713 https://github.com/i18next/react-i18next/issues/1534

Is it possible to use this approach (using text as keys for default locale) without a noisy console?

thank you for your time