A memo on how to implement internationalization (i18n) for state_machine.
・pluginaweek/state_machine · GitHub
■ config/locales/model.ja.yml
ja:
activerecord:
state_machines:
order:
state:
states:
accepted: 注文受付
firmed: 注文確定
cancelled: 注文キャンセル
delivered: 発送完了
events:
accept: 注文
cancel: キャンセル
deliver: 発送
errors:
models:
order:
attributes:
state:
invalid_transition: "%{value}状態では%{event}処理はできません。"
Then use it with human_state_name.
o.human_state_name
# => "発送完了"
【Reference】
・I18n documentation is missing · Issue #114 · pluginaweek/state_machine
That’s all from the Gemba.