For a web extension messages.json
translation file, is it possible that a translation includes another translation? That would be useful when you want to avoid duplication.
For example something like:
{
"greeting": {
"message": "Hello, $NAME$!",
"placeholders": {
"name": {
"content": "$first_name$"
}
}
},
"first_name": {
"message": "John"
}
}
Neither the above approach of referring to another message using $<name>$
nor using __MSG_<name>__
within messages.json
seem to work. I am looking for something which ideally works for Chrome and Firefox.
A workaround might be to nest getMessage
calls and use $1
as placeholder in the message, but that is rather verbose and error-prone because every caller which wants to obtain the translation has to do this:
browser.i18n.getMessage('greeting', browser.i18n.getMessage('first_name'))