Volodymyr Petlovy
Volodymyr Petlovy

Reputation: 117

Rails i18n has_one translation

model:

has_one :small_image, :class_name => 'Image', :foreign_key => :sub_category_id, :dependent => :destroy

yml:

ua:
  activerecord:
    attributes:
      sub_category:
        top_category_id: "Головна категорія"
        name: "Назва"
        description: "Опис"
        small_image:
          attributes:
            file_name: "Ім’я файлу"

view:

<%= f.fields_for :small_image do |image| %>
      <div class="control-group">
        <%= image.label(:file_name, :class => "control-label") %>
....

question: why it shows "File name" instead of "Ім’я файлу" in the browser, the rest of labels are correct

Upvotes: 1

Views: 310

Answers (1)

Volodymyr Petlovy
Volodymyr Petlovy

Reputation: 117

thanks for this article: http://www.unixgods.org/~tilo/Rails/which_l10n_strings_is_rails_trying_to_lookup.html

in my case for labels it should be:

ua:
  helpers:
    label:
      sub_category[small_image_attributes]:
        file_name: "Ім’я файлу"

and for error messages:

ua:
  activerecord:
    attributes:
      sub_category:
        top_category_id: "Головна категорія"
        name: "Назва"
        description: "Опис"
      sub_category/small_image:
        file_name: "Ім’я файлу"

Upvotes: 1

Related Questions