:string %> The regula...">

Avoiding the colon: on the i18n rails?

Here is the line in the view:

<%= f.input :comm_date, :label => "Hello:", :as => :string %> 

The regular i18n file has the format:

  Hello : 'Aloha' 

In the i18n yml file we want to translate "Hello:" like, for example, "Aloha:". Can we escape the colon: by doing below?

'Hello:': 'Aloha:'

Or what is the right way to avoid colon?

+4
source share
2 answers

Here's what we did:

 'Hello:' : 'Aloah' 

Just use a single quote and it worked.

+1
source

The stone you use, simple_form, as well as other similar ones, such as formtastic, allow you to use translation files (for example, en.yml ) to define your tag text.

You can see the expectations of the translation file from the simple_form documentation. Using your example, you will need two translations, something like this, if your model is called Communication :

en.yml

 en: simple_form: labels: communication: comm_date: "Hello:" 

olelo.yml

 olelo: simple_form: labels: communication: comm_date: "Aloha:" 

And your look will be simple

 <%= f.input :comm_date, :as => :string %> 

No need to specify a value for the parameter :label .

+4
source

Source: https://habr.com/ru/post/1479768/


All Articles