Closed ljosberinn closed 4 years ago
👍PR welcome....@slevy85 you might also look into this?
I am sorry for this I introduced a regression, the problem is version === local.i18nVersion
compares empty string with undefined, with double equals it would workd but a better solution is to intialize defaultVersion to undefined.
Hi,
noticed that my geti18n endpoint receives requests although its data is definitely already stored. Providing
defaultVersion: anyString
fixed it.https://github.com/i18next/i18next-localstorage-backend/blob/master/src/index.js#L33 ensures the default version is an empty string
https://github.com/i18next/i18next-localstorage-backend/blob/master/src/index.js#L85 falls back to the defaultValue if none was provided for the current language right after, it checks whether a version was found and only then sets it -
''
is falsy though, so the value won't get sethttps://github.com/i18next/i18next-localstorage-backend/blob/master/src/index.js#L69 which leads to this always being false, leading to a permanent refetch
proposed solutions:
save
:data.i18nVersion = this.getVersion(language);
- would lead to an unecessary key in localStorage thoughthis.options.defaultVersion
inread
Both sound kinda stupid to me right now, but that's because I've been debugging this for an hour and now its past 4 am. :sweat_smile: I can create a PR later.