question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allowing LocaleMessage to be Functions

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kazuponcommented, Aug 12, 2020

@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. 😃

1reaction
exoegocommented, Aug 11, 2020

Great thanks for proposal! This sounds worth to have for many languages. Pull requests are welcome 🙏

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found