This might be I18n-ception but lets say I have an en.yml
file as below
en: my_var: Foo my_message: "This is a message where I'd like to interpolate I18n's %{my_var}"
Is there a way to indicate to I18n that %{my_var}
should be the my_var
key in en.yml
?
I know I could accomplish it by doing something like
I18n.t 'my_message', :my_var => I18n.t('my_var')
but I was hoping I18n has a way to self reference keys.
Interpolation. Interpolation is one of the most used functionalities in I18N. It allows integrating dynamic values into your translations. Per default, interpolation values get escaped to mitigate XSS attacks.
Meaning of interpolation in English. the addition of something different in the middle of a text, piece of music, etc. or the thing that is added: An actor reads the poems in English translation, with brief musical interpolations.
The Ruby I18n (shorthand for internationalization) gem which is shipped with Ruby on Rails (starting from Rails 2.2) provides an easy-to-use and extensible framework for translating your application to a single custom language other than English or for providing multi-language support in your application.
i18next is an internationalization-framework written in and for JavaScript. But it's much more than that! i18next goes beyond just providing the standard i18n features such as (plurals, context, interpolation, format). It provides you with a complete solution to localize your product from web to mobile and desktop.
This is actually a pretty common question, but the short answer is no, this isn't possible unfortunately :(
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With