geekq / workflow

Ruby finite-state-machine-inspired API for modeling workflow
MIT License
1.75k stars 207 forks source link

localization of states and events (i18n) #101

Closed fabianoarruda closed 10 years ago

fabianoarruda commented 10 years ago

Is that possible? My ideia is that you could have a .yml file with the translations of the states and events of a given model, then I could call it on my views... something like:

<%= t object.current_state %>

What do you guys think?

miletbaker commented 10 years ago

I just create another method, i.e.

def state_label
  I18n.t "models.<model name>.#{current_state}"
end

The put your translations directly into your yml file under, i.e. for a model post in the en.yml file:

...
en:
  models:
    post:
      draft: "Draft"
      published: "Published"
...
geekq commented 10 years ago

I would also suggest creating a separate method as suggested by @miletbaker