-4

I use i18n for View at Rails4.

My Rails YAML file and HTML(ERB) file

YAML

this is the YAML file(for Japanese).

---
ja:
  MODEL_NAMEs:
    edit:
      title: 編集:%{model}

HTML

this is html file written by erb.

<h2><%= t('.title') %></h2>

Result of View

enter image description here

Question

How to replace the placeholder(in this case %{model}), automatically model name?

P.S

@Amit Sharma advice.

ja:
  MODEL_NAMEs:
    edit:
      title: "編集:%{model}"

and

<h2><%= t('MODEL_NAMEs.edit.title', model: "test") %></h2>

and rails restart. then 編集:test was shown.
so. model is may be nil or something.

I want to

<h2><%= t('.title') %></h2> #=> 編集:MODEL_NAME

Do not rails auto insert model?
I think auto insert %{model}. because submit work so.

I18n for model-specific Rails submit button

shingo.nakanishi
  • 2,045
  • 2
  • 21
  • 55
  • 2
    You can try this `"title: 編集:%{model}"` in .yml and in view `

    <%= t('MODEL_NAMEs.edit.title', model: "test") %>

    `
    – Amit Sharma Sep 15 '15 at 07:17

1 Answers1

2

You can try this, I hope this will help.

in YML File.

ja:
  MODEL_NAMEs:
    edit:
      title: "編集:%{model}"

in View File.

<h2><%= t('MODEL_NAMEs.edit.title', model: "test") %></h2>
Amit Sharma
  • 3,427
  • 2
  • 15
  • 20