This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 783
Translating your app
GregSilcox edited this page Oct 16, 2012
·
5 revisions
To use translations in your app define some yaml like this:
# en.yml
en:
unauthorized:
manage:
all: "You have no access!"
If you want to customize messages for some model or even for some ability define translation like this:
# models/ability.rb
...
can :create, Article
...
# en.yml
en:
unauthorized:
create:
article: "Only admin may do this!"
Also translations is available for your custom abilities:
# models/ability.rb
...
can :vote, Article
...
# en.yml
en:
unauthorized:
vote:
article: "Only users which have one or more article may do this!"
Finally you may use action
(which contain ability like 'create') and subject
(for example 'article') variables in your translation:
# en.yml
en:
unauthorized:
manage:
all: "You do not have access to %{action} %{subject}!"
Enjoy!
This project is abandoned, see its successor: CanCanCan