Skip to content
Rafael Carvalho edited this page Aug 22, 2017 · 8 revisions

AASM supports i18n !

To use the translated version of a state, call this:

job.aasm.human_state

To provide a translation you can use the following format:

en:
  activerecord:
    attributes:
      job:
        aasm_state:
          cleaning: Cleaning Up
          running: Working
          sleeping: Asleep

But beware that it can conflict if you're using the following code:

Job.human_attribute_name(:aasm_state)

The solution in this case is to use the following format:

en:
  activerecord:
    attributes:
      job:
        aasm_state: State
        aasm_state/cleaning: Cleaning Up
        aasm_state/running: Working
        aasm_state/sleeping: Asleep

aasm_state is the default column name for state (https://github.com/aasm/aasm#sequel).

If you have changed this one with a custom column name (https://github.com/aasm/aasm#activerecord-enums) you have to change the locale keys accordingly.

For example, if you have named aasm column "status" you have to use the following format:

en:
  activerecord:
    attributes:
      job:
        status: State
        status/cleaning: Cleaning Up
        status/running: Working
        status/sleeping: Asleep