Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n Event translations failing #721

Closed
fedeagripa opened this issue Oct 22, 2020 · 3 comments
Closed

i18n Event translations failing #721

fedeagripa opened this issue Oct 22, 2020 · 3 comments

Comments

@fedeagripa
Copy link

fedeagripa commented Oct 22, 2020

Describe the bug
I'm trying to display transition events in an admin page, and so events translation are not working 馃槥
I'm I missing something or miss reading it, or is actually not working?

To Reproduce
Steps to reproduce the behavior:
1 - Define translations for any of your event models. In my case I have Order with process event for example.
2 - Call order.aasm.events(permitted: true).map(&:name)

Expected behavior
I would expect that my call to mymodel.aasm.events.map(&:name) return my possible transition events translated given my es.yml

Screenshots
Translations

es:
  activerecord:
    events:
      order:
        process: 'Procesar'
        accept: 'Aceptar'

Active Admin call

action_item :change_status, only: :show do
    order = Order.find(params[:id])
    dropdown_menu 'Admin' do
      order.aasm.events(permitted: true).map do |state|
        item state.name, advance_admin_order_path(state: state.name)
      end
    end
  end

Output:
image
(I should be in Spanish according es.yml)

Additional context
I was checking spec/en.yml for some context about how to build my events translations.
But this is not displayed properly

@anilmaurya
Copy link
Member

@the-spectator can you help on this issue ?

@the-spectator
Copy link
Contributor

the-spectator commented Oct 23, 2020

@fedeagripa Event localization can be accessed using Model.aasm.huma_state_name(event_object.name or symbol) .

Order.aasm.human_event_name(:process)

To extend your example:

order.aasm.events(permitted: true).map do |event|
  localized_event_name = Order.aasm.human_event_name(event.name)
  item localized_event_name, advance_admin_order_path(state: state.name)
end

I hope this resolves your issue/question.

@fedeagripa
Copy link
Author

@the-spectator amazing, that worked, thanks!
Feel free to close this issue then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants