Cannot extract using i18n.plural : undefined is not iterable!
See original GitHub issueHello, we use lingui v2.9.2 and we got issue extracting using i18n.plural
:
This works:
export function _(
id: MessageDescriptor | string,
values?: Record<string, unknown>,
messageOptions?: MessageOptions
): string {
if (typeof id === 'string') {
return i18n._(id, values, messageOptions)
}
return i18n._(id)
}
This fail:
export function _(id: MessageDescriptor | PluralProps): string {
return !Object.prototype.hasOwnProperty.call(id, 'one')
? i18n._(id as MessageDescriptor)
: i18n.plural(id as PluralProps)
}
It fails when we run lingui extract --clean
, with the following error:
TypeError: src/libs/i18n.ts: undefined is not iterable!
at module.exports.require.getIterator (/home/dka/workspace/github.com/pass-culture/pass-culture-app-native/node_modules/babel-runtime/node_modules/core-js/library/modules/core.get-iterator.js:5:42)
at Transformer.transformChoiceMethod (/home/dka/workspace/github.com/pass-culture/pass-culture-app-native/node_modules/@lingui/babel-plugin-transform-js/transformer.js:199:56)
at Transformer.transformMethod (/home/dka/workspace/github.com/pass-culture/pass-culture-app-native/node_modules/@lingui/babel-plugin-transform-js/transformer.js:393:21)
at PluginPass.Transformer.transform (/home/dka/workspace/github.com/pass-culture/pass-culture-app-native/node_modules/@lingui/babel-plugin-transform-js/transformer.js:69:25)
at newFn (/home/dka/workspace/github.com/pass-culture/pass-culture-app-native/node_modules/babel-traverse/lib/visitors.js:276:21)
at NodePath._call (/home/dka/workspace/github.com/pass-culture/pass-culture-app-native/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/home/dka/workspace/github.com/pass-culture/pass-culture-app-native/node_modules/babel-traverse/lib/path/context.js:48:17)
at NodePath.visit (/home/dka/workspace/github.com/pass-culture/pass-culture-app-native/node_modules/babel-traverse/lib/path/context.js:105:12)
at TraversalContext.visitQueue (/home/dka/workspace/github.com/pass-culture/pass-culture-app-native/node_modules/babel-traverse/lib/context.js:150:16)
at TraversalContext.visitSingle (/home/dka/workspace/github.com/pass-culture/pass-culture-app-native/node_modules/babel-traverse/lib/context.js:108:19) {
_babel: true
}
We rather use the synthax of i18n.plural
instead of i18n._
, how can this be fixed ?
Reproduction
git clone https://github.com/pass-culture/pass-culture-app-native.git
cd pass-culture-app-native
nvm use
yarn
yarn run translations:extract
Related issues
Issue Analytics
- State:
- Created 2 years ago
- Comments:74 (33 by maintainers)
Top Results From Across the Web
TypeError: undefined is not iterable (cannot read property ...
In my case, the error was happening simply because the array I was iterating over had undefined as it's ...
Read more >Plurals - i18next documentation
How to find the correct plural suffix? You can use this small utility to get the correct plural suffixes. Or try translation-check, it...
Read more >ChangeDetection - Comparison of: Bean Validation specification
Anynot use of the Specification and the information described therein ... The lifecycle of a constraint validation implementation instance is undefined.
Read more >Objects - Docassemble
The objects block declares that user is an instance of the class Individual . Objects have “attributes.” In the above example, name is...
Read more >https://svn.python.org/projects/external/Jinja-2.1...
By default two example extensions exist: an i18n and a cache extension. ... name.value not in variables: parser.fail('unknown variable %r for pluralization' ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Quick update:
One thing we can’t fix without breaking others users, it’s not stripping spaces at the end of strings.
Not inmediately fix
For example this case:
Should be like this if you want that space, or
" "
:Inmediately fix
Pending for your side confirmation
Pending for my side
Thanks, I was still working on my boilerplate, so I am giving up. I will try to see if there’s a way to start the application without those keys to see if we can investigate further.