Open jmlavoier opened 2 months ago
Three points to consider to solve this problem.
I've tested the i18next in node environment and the browser and got different results. I realized that the many
possibility is coming only on node environment.
This simple implementation got different results:
import i18next from "i18next";
i18next.init({
pluralSeparator: "_",
nsSeparator: ":",
});
i18next.services.pluralResolver
.getSuffixes("unknown", { ordinal: undefined })
.forEach((suffix) => {
console.log("suffix", suffix);
});
suffix: _one
suffix: _other
In this case, the test should not fail.
suffix _one
suffix _many
suffix _other
Due to the many
the test is failing
For both tests I used i18next v23.5.1
So if there is a compatibility issue, maybe it's necessary identify what's needs to be fixed to make it consistent on both environments. I know that it should not be executed on browser, but considering that the test is breaking in node environment that is the more common to be executed.
Considering that the many
is not a problem, we would change the test to accept the many
.
i18nextParser.once('end', () => {
assert.deepEqual(result, {
'test {{count}}_one': '',
'test {{count}}_many': '', // <- Add this to the assert
'test {{count}}_other': '',
})
done()
})
Finally, we should question whether this test is necessary. Since this behavior is part of the i18next library, testing it here introduces unnecessary dependency on external behavior. The responsibility of pluralization lies with i18next, not our library. If there is an issue with i18next, the problem should be addressed within that library, not through our tests.
Let's discuss about these points and decide which solution fits better to this issue so that I can create a PR to sort it out.
🐛 Bug Report
Running the
yarn test
To Reproduce
Expected behavior
Taking into consideration that I haven't changed anything in the codebase and I'm running it on the master branch, which is supposed to be the production-ready version, the test should run successfully.
Your Environment