i18next-parser
i18next-parser copied to clipboard
Parsing translation with `returnObjects: true` replaces the object with a string
-
Is this a bug or a feature request? Bug
-
What version are you running (
0.x
or1.x
)? 1.0.6 -
Which runner (cli, gulp...)? cli
What I'm trying to do?
I have a namespace for translating country names. I want to request this as an object, so that I can simply iterate through the countries.
t('country:countries', { returnObjects: true })
{
"countries": {
"AFGHANISTAN": "Afghanistan",
"ALAND_ISLANDS": "Aland Islands",
"ALBANIA": "Albania",
"ALGERIA": "Algeria",
...
How am I doing it?
Here is my config file:
module.exports = {
input: ['src/**/*.{ts,tsx,js}'],
output: 'i18n/$LOCALE/$NAMESPACE.json',
// only write to english, since it is the fallback for other languages
// which would be translated externally
locales: ['en'],
};
The command I'm running:
i18next
What was the result?
After parsing, the countries
object is replaced with a blank string
{
"countries": ""
}
What was I expecting?
Translations that are marked as returning objects should not be parsed as having a string result. I would expect this to have been ignored.
It's not per say a bug but a missing feature. The parser doesn't support the returnObjects
option, I didn't even know it existed. You are welcome to submit a PR with the change, I don't have lots of time to work on this project atm.
Okay, good to know! I will see about submitting a fix
Any update on this? 😅
This would be extremely helpful
Feel free to submit a PR
Same Problem
Is this project maintained any more? We're looking for a parsing module for i18n but if issues like this are getting ignored for 3+ years then maybe this one is not a good idea to adopt. Thank you.
@steodor The eternal question of open-source and its entitled users. Instead of expecting things to be fixed, I invite you to contribute either with code or financially to ensure things that are important to you get fixed.
On a personal note, I've been clear for years that I don't use this project and have very limited bandwidth to write code for it. I review PRs and publish new versions regularly though. If you need custom work on the parser for your company needs, you can hire me.