i18n-msg icon indicating copy to clipboard operation
i18n-msg copied to clipboard

support placeholders similar to Chrome.i18n APIs

Open kvsrohit opened this issue 9 years ago • 1 comments

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

kvsrohit avatar Jun 25 '16 18:06 kvsrohit

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.

kvsrohit avatar Jun 25 '16 18:06 kvsrohit