全球化重复的语言环境

时间:2019-01-16 09:45:06

标签: ruby-on-rails globalize

当我创建一个新的管理员用户时,有三个翻译对象:

Admin.last.translations.map(&:locale) # => [:ru, :uz, :uz]

为什么区域设置重复?

示例:

admin.position_uz = 'CTO'
admin.position_ru = 'CTO'
admin.save!

admin.translations.count = 3
admin.translations.first.position = 'CTO'
admin.translations.second.position = 'Another value or empty'
admin.translations.third.position = 'CTO'

每次将区域设置设置为uz时,都会显示第二个变体。

管理员翻译看起来像

[
  #<Admin::Translation id: 1, admin_id: 2, locale: "ru", position: "CTO", created_at: "2019-01-16 06:24:17", updated_at: "2019-01-16 06:30:31">,
  #<Admin::Translation id: 2, admin_id: 2, locale: "uz", position: "Board Member", created_at: "2015-07-26 20:42:18", updated_at: "2015-07-26 20:42:18">,
  #<Admin::Translation id: 3, admin_id: 2, locale: "uz", position: "CS manager", created_at: "2019-01-16 06:24:17", updated_at: "2019-01-16 07:09:21">
]

0 个答案:

没有答案