I have script that write log messages like this:
<i18n param1="value1" param2="value2">translation_template</i18n>
Parameters amount and names may be various. Message, parameters names and values I gets using regular expression, after that I have data
{
message: 'translation_template'
param1: 'value1'
param2: 'value2'
}
And I want translate that messages using Ruby on Rails internalization.
Method i18n.t
can pass parameters and use them in translation:
t 'translation_template', param1: 'value1', param2: 'value2'
If localization file has row
some_lang:
translation_template: "Translated %{param1} is %{param2}"
User will see Translated value1 is value2
But this syntax implies a certain number of parameters.
How to pass previously unknown parameters set? For example, via hash, something like this:
t 'translation_template', { 'param1': 'value1', 'param2': 'value2'}