Impossible to add pluralizationRules via the vueI18n options
See original GitHub issueVersion
Reproduction link
Not really needed
Steps to reproduce
- In
nuxt.config.js
, within the options for thenuxt-i18n
module, add avuei18n
option - Add
pluralizationRules: {'en': function(choice, choicesLength) { return 0 }}
object - run
npm run dev
What is expected ?
The generated .nuxt/nuxt-i18n/plugin.main.js
file should initialize new VueI18n
with pluralizationRules: {'en': function(choice, choicesLength) { return 0 }}
parameter
What is actually happening?
pluralizationRules
is an empty object
Additional comments?
This happens because the vuei18n
options get stringified using JSON.stringify
here. The result of JSON.stringify({foo: function() {return 'bar'}})
is an empty object as the method serializes function as null
value as you can see here
The option to initialize VueI18n
with pluralization rules was added recently (see discussion)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:7
Top Results From Across the Web
Pluralization | Vue I18n
In order to implement these rules you can pass an optional pluralizationRules object into VueI18n constructor options.
Read more >Impossible to add pluralizationRules via the vueI18n options
In nuxt.config.js , within the options for the nuxt-i18n module, add a vuei18n option; Add pluralizationRules: {'en': function(choice, ...
Read more >Pluralization | Vue I18n
These plural messages are selected by the logic of the choice rule for each language in the translaton API according to the numeric...
Read more >Vue i18n: Building a multi-language app with locale switcher
Installing and setting up Vue I18n. Adding support for multiple languages. Storing and using translations. Implementing pluralization.
Read more >The Ultimate Vue Localization Guide | Phrase
Dive into Vue localization and learn how to plug the Vue I18n library into your app, so you can make it accessible to...
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
@lukaVarga try
pluralRules
instead ofpluralizationRules
Passing functions through module options would require serialization of function and that is, while possible, generally discouraged by core team. Better option is to support external configuration file that would be
require
d by the module. Then you can use functions without problems.But I agree it should be re-opened.