formatjs / handlebars-intl

Handlebars helpers for internationalization.
http://formatjs.io/handlebars/
Other
265 stars 28 forks source link

Using `formatMessage` in a loop construct #83

Open vcatalano opened 7 years ago

vcatalano commented 7 years ago

There doesn't appear to be a way to use the formatMessage directive in a loop construct with messages containing variable numbers of arguments. For example, I have an array containing messages, however, each message does not take the same arguments:

{{#messages}}
  {{formatMessage (intlGet messageText)
      num=??
      ago=??}}
{{/messages}}
var messages = [
  { messageText: "Welcome, {user}!" },
  { messageText: "How are you today, {firstName} {lastName}?" }
];

Is it possible to handle dynamic arguments with the formatMessage directive?