The short answer, I believe, no, you cannot do line interpolation in YAML the way you want using an alias .
In your case, what would I do, there is something like the following in my locale file:
en: site_name: "Site Name" static_pages: company: description: ! '%{site_name} is an online system'
and then call the corresponding view with the site name as a parameter:
t('.description', site_name: t('site_name'))
which will bring you the "Site Name is an online system" .
However, if you are desperate to use aliases in your YAML file to concatenate strings together, the following completely unsuitable code will also work if the string is two elements of an array:
en: site_name: &site_name "Site Name" static_pages: company: description: - *site_name - "is an online system"
and then you would join array in the appropriate form as follows:
t('.description').join(" ")
Which will also bring you the "Site Name is an online system" .
However, before you decide to go this route, besides the question related to @felipeclopes, look:
- this StackOverflow answer regarding string concatenation i18n (tl; dr Please, not for your translation team).
- StackOverflow questions here and here , similar to your question.
Paul Fioravanti Dec 19 2018-12-12T00: 00Z
source share