Open cmosboss opened 6 years ago
@zocheyado that missingKeyHandler is i18next "land" means if set you take care of handling missing keys yourself and the backend won't be triggered.
So i would suggest this change:
// ...
i18next
.use(backend)
.use(LanguageDetector)
.init({
debug: false,
fallbackLng: 'en',
preload: ['en', 'es', 'zh-Hans', 'zh-Hant'],
ns: ['common', 'events', 'validation'],
saveMissing: true,
missingKeyHandler: loadFromLocal ? (lng, ns, key, fallbackValue) => {
// eslint-disable-next-line
console.error('Missing key in translations', lng, ns, key, fallbackValue);
} : false,
load: 'languageOnly', // Remove if you want to use localization (en-US, en-GB)
}, error => {
if (error) {
// eslint-disable-next-line
console.error('Error loading i18next', error);
throw error;
}
});
// ...
this way that missingKeyHandler gets only set if not using loadFromLocal...
I seem to have found my issue. I added that in during testing to confirm that keys are missing. If I remove that it still does not add the key unless I actually get my code to execute that error message. This is fine I will just have to find a way to get the error messages pre uploaded so they can be translated ahead of time. Thanks!
yes...it's not a translation extraction tool...missing works by actually calling that t function for that key. Alternatively you might have a look into:
https://github.com/i18next/i18next-parser
or
https://github.com/i18next/i18next-scanner
to extract translations and import those to locize.
I am having some trouble figuring out how to add new keys to locize via node. Old developer had setup everything, and I have since added ~40 keys I need to add to the locize service. Below is our locize setup / init. loadFromLocal is false and it is running the "Backend" section of the code.
As you can see we have a "Missing Key Handler" and it is indeed firing on all of my new keys, but none of this is going to locize. What am I missing?