Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolation in I18n array #281

Open
Bartuz opened this issue Aug 25, 2014 · 3 comments
Open

Interpolation in I18n array #281

Bartuz opened this issue Aug 25, 2014 · 3 comments
Milestone

Comments

@Bartuz
Copy link
Contributor

Bartuz commented Aug 25, 2014

According to: http://stackoverflow.com/questions/21574900/interpolation-in-i18n-array/25484080#25484080
Say my locale file looks like this:

en:
  my_array:
    - "Line 1"
    - "Line 2"
    - "Line 3 has a %{variable}"
    - "Line 4"

I want the output of I18n.t('my_array', :variable => 'variable named variable') to be as follows:
["Line 1", "Line 2", "Line 3 has a variable named variable", "Line 4"]

However, the output is:
["Line 1", "Line 2", "Line 3 has a %{variable}", "Line 4"]

@radar radar added this to the 0.8.0 milestone Nov 15, 2016
@radar radar removed the pr-required label Nov 15, 2016
@radar radar modified the milestones: 0.9.0, 0.8.0 Nov 20, 2016
@sandstrom
Copy link
Contributor

sandstrom commented Dec 4, 2016

I don't think supporting this would be a good thing.

If you want to break translation across multiple lines yaml already allow that:

en:
  my_text: |
    line 1
    line 2
    line 3

and if you want to make e.g. paragraphs in html you could do

I18n.t('my_text').split("\n").each { |line| print "<p>#{line}</p>" }

or use something like simple_format

@Chiether
Copy link

I am request too; case example CSV-header.
settle for
I18n::Backend::Simple.new.send(:interpolate, args...)
for the time being to me.

@EddieOne
Copy link

EddieOne commented Jun 5, 2017

When converting json or key/values to yaml, integer keys will get converted to arrays.

@radar radar modified the milestones: 0.9.0, 0.10.0 Oct 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants