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

addPath seems not working #47

Open
anatoly314 opened this issue Apr 2, 2024 · 1 comment
Open

addPath seems not working #47

anatoly314 opened this issue Apr 2, 2024 · 1 comment

Comments

@anatoly314
Copy link

🐛 Bug Report

It seem that addPath not working, neither with ChainedBackend, neither stand alone, neither yaml, neither json, I have tried every possible options. The file with missing keys not created. No exception is thrown. Please advice.

To Reproduce

import i18n from 'i18next'
import FsBackend from 'i18next-fs-backend'
import ChainedBackend, {ChainedBackendOptions} from "i18next-chained-backend";

const i18nextOptions = {
    debug: true,
    initImmediate: false,
    fallbackLng: 'en',
    lng: 'en',
    preload: ["en", "de"],
    ns: 'translation',
    defaultNS: 'translation',
    backend: {
        backends: [
            FsBackend,
        ],
        backendOptions: [{
            loadPath: './src/i18n/locales/{{lng}}/{{ns}}.yaml',
            addPath: './src/i18n/locales/{{lng}}/{{ns}}.missing.json',
            // expirationTime: 7 * 24 * 60 * 60 * 1000, // 7 days
        }]
    }
}


i18n
    .use(ChainedBackend)
    .init<ChainedBackendOptions>(i18nextOptions)


await i18n.changeLanguage("en")
console.log(i18n.t('home.title', {
    lng: "de"
}))

console.log(i18n.t('home.missing'))

Expected behavior

File translation.missing.yaml will be created with home.missing key

Your Environment

  • runtime version: node v20.10.0
  • i18next version:
      "i18next": "^23.10.1",
     "i18next-chained-backend": "^4.6.2",
     "i18next-fs-backend": "^2.3.1",
    
  • os: Mac
@adrai
Copy link
Member

adrai commented Apr 3, 2024

saveMissing: true

https://www.i18next.com/overview/configuration-options#missing-keys

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

No branches or pull requests

2 participants