Allowing LocaleMessage to be Functions
See original GitHub issueI am trying to do something pretty complex. Here is an example that I have in French of different translations:
- Manger de la soupe
- Manger une pomme
- Manger du pain
- Manger de l’orge
As you can see, the article preceding the noun will vary based on gender and phonetics.
Proposal
If we could have functions as a LocaleMessage, it would allow doing these more complex translations. Example
export default {
fr: {
sentence: function (values) {
let article
if (values.word.startsWith(...)) {
article = "de l'"
} else {
article = 'du'
}
return `Manger ${article} ${value['word']}`
}
}
}
Thoughts? Comments?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Issuehunt
Allowing LocaleMessage to be Functions #969 ... If we could have functions as a LocaleMessage, it would allow doing these more complex translations....
Read more >Message Format Syntax - Vue I18n
In the locale message above, you can localize it by giving the JavaScript defined msg as a parameter to the translation function. The...
Read more >Locale messages syntax | Vue I18n
As Flowtype definition, Locale Messages syntax like BNF annotation type LocaleMessages = { [key: Locale]: LocaleMessageObject } ...
Read more >vue-i18n-locale-message/tsconfig.json at master - GitHub
vue-i18n-locale-message/tsconfig.json ... "strictFunctionTypes": true, /* Enable strict checking of function types. */. // "strictBindCallApply": true ...
Read more >The Ultimate Vue Localization Guide | Phrase
Vue I18n allows us to extend its plural. // formatting by providing one form selector. // function per locale. pluralizationRules: {.
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
@philippevezina
This proposal is good too me, because it will be fully customizable for each language.
To adopt this proposal into vue-i18n, I will try to think in a bit of function I/O specs, in order to maintain compatibility with vue-i18n-next.
In any case, this proposal was a good inspiration for the vue-i18n-next compiler like the Vue render functions. I would like to improve the specification of the msg function generated by the vue-i18n-next compiler by including this proposal. 😃
Great thanks for proposal! This sounds worth to have for many languages. Pull requests are welcome 🙏