i18n-msg
i18n-msg copied to clipboard
support placeholders similar to Chrome.i18n APIs
Hi Eric, I've redone benjaminpg's changes on latest clone with minor changes and slight variation on demo and test cases. You may want to checkout.
Cheers//rohit
Placeholders
It's possible to insert text within the message which requires no translation (e.g: names, dates, numbers). To make available the use of placeholders the message must contain placeholders in Chrome.i18n format ($name$) whenever a parameter should be used, and to use these add the attribute "placeholders" having value array. Example:
"error": {
"message": "Error: $details$",
"description": "Generic error template. Expects error parameter to be passed in.",
"placeholders": {
"details": {
"content": "$1",
"example": "Failed to fetch RSS feed."
}
}
}
<i18-msg msgid="error" placeholders='["Failed to fetch data."]'></i18n-msg>
It's also possible to use {{}} and [[]] within the placeholders.