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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alphabetical ordering of keys that can contain each other breaks i18next #2130

Closed
briandipalma opened this issue Jan 31, 2024 · 3 comments
Closed

Comments

@briandipalma
Copy link

馃悰 Bug Report

This resource file blows up i18next:

{
  "currency-search.placeholder": "Seleccione el Par de Divisa",
  "currency-search.placeholder.short": "Par de Divisas"
}

With this stack trace:

i18next.js:229 Uncaught TypeError: Cannot set properties of undefined (setting 'undefined')
    at setPath (i18next.js:229:10)
    at ResourceStore.addResource (i18next.js:419:7)
    at ResourceStore.addResources (i18next.js:429:122)
    at _this2.<computed> [as addResources] (i18next.js:2161:50)

Specifically this code:

function setPath(object, path, newValue) {
  var _getLastOfPath = getLastOfPath(object, path, Object),
    obj = _getLastOfPath.obj,
    k = _getLastOfPath.k;
  obj[k] = newValue; // <-- THIS LINE HERE
}

You can see the state of the code when it blows up:

image

So basically because the first key is a subkey of the next key to be added getLastOfPath returns an empty object because the subkey has already set the value of its path to a string so canNotTraverseDeeper short-circuits the tree creation.

@adrai
Copy link
Member

adrai commented Jan 31, 2024

Which i18next version did you use?
Can you reproduce it with v23.7.20 and with v23.8.1?

if it works with v23.7.20 I assume this PR introduced a regression //cc: @hsource

@adrai
Copy link
Member

adrai commented Jan 31, 2024

Ok, I think that is not related to that PR

@adrai adrai closed this as completed in 002268b Jan 31, 2024
@adrai
Copy link
Member

adrai commented Jan 31, 2024

please try with v23.8.2

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