how to pass args to the i18n messages
See original GitHub issueVersions:
- VueJs: 2.5.17
- Vee-Validate: 2.1.0-beta.9
Description:
Hey there, it’s a question. I want to know how to pass args to the i18n messages, I don’t found any example.
for better explanation, an example:
I have a validator min (minlength)
export default (value, [length]) => {
length = Number(length);
return value.length >= length;
};
And I’ve a validation message in i18n object
Digite no mínimo {length} caracteres
I want to use the length arg to generate the i18n message correctly.
(To manage the i18n messages, I’m using the vue-i18n library.)
I saw in this line the I18nDictionary.getMessage pass a data param to Vuei18n.t , but I can’t understand hot to use exactly (if it’s possible)
Thank you!
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to pass arguments in I18n.translate - Stack Overflow
You can pass the params after the key. I18n.translate('error.messages.greater_than_or_equal_to', count: 2).
Read more >How To Pass a Variable to Your Translation String With i18next
Here, we looked at how to pass one or more parameters to your i18next translation strings. This can be easily achieved by taking...
Read more >Interpolation - i18next documentation
By default, the values get escaped to mitigate XSS attacks. You can toggle escaping off, by either putting - before the key, or...
Read more >Message Format Syntax - Vue I18n
The first argument is message.hello as the locale messages key, and the second argument is an object with msg property as a parameter...
Read more >passing parameter to the i18n text from xml view in fiori app
So you have to create a formatter and pass all the strings to the formatter and then do it inside JS. In JS...
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 Free
Top 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

I’m not related to this project, but here is how I did it. VueI18n does not accept functions, only strings. But you can use
{0}for the first function argument and{1}for the second (and so on). So In my case:messages.js
I do however believe you can use
VeeValidate.Validator.localize()to convert your vee-validate message functions to strings…So far I think vee-validate handles localization better than Vuei18n.
Thank you @ssnetxyz, using
{1}I can use the param value in message.{0}is field name{1}is param values{2}is data valuesFor advanced interpolation I think is necessary create a custom formatter, because I can’t use named params in the message, but it is just curiosity haha