Search code examples
ruby-on-railsrails-i18ni18n-gem

Specific activerecord attributes becomes translation missing on production with Rails i18n


My default locale is :ja, and I have this for user.ja.yml:

ja:
  activerecord:
    models:
      user: プロフィール
    attributes:
      user:
        account_id: アカウントID
        birth_day: 生年月日
        email: メールアドレス
    errors:
      user:
        invalid_zip_code: 郵便番号に該当する住所がみつかりません。  
  enumerize:
    user:
      sex:
        man: 男性
        woman: 女性

My application raises a translation missing error on a specific model on the production server. It works fine on other models and on development and local production environments.

On local production environment:

I18n.t('activerecord.attributes.user.account_id')
# => "アカウントID"

On production server:

I18n.t('activerecord.attributes.user.account_id')
# => "translation missing: ja.activerecord.attributes.user.account_id"

activerecord.model does not raise an error:

I18n.t('activerecord.models.user')
# => "プロフィール"

Solution

  • I've found the solution. There was a locale file which has no content on attributes.

    ja:
      activerecord:
        models:
          authentication: SNS連携
        attributes:
    

    This file affects other files.