iGEL / it

A helper for links and other html tags in your translations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

update documentation for how to use this in a controller

ccmcbeck opened this issue · comments

Terrific gem.

It can be done on a one-off basis in Rails 3+ using view_context.it(key,...)
But the preferred method is probably this:

class ApplicationController < ActionController::Base
  include It::Helper

Very useful for controller flash messages like this:

if @invitation.accepted?
  flash[:notice] = it('flash.invitation_accepted_already', link: new_password_reset_path)

with en.yml like this:

flash:
  invitation_accepted_already:
    This invitation has already been accepted.
    Sign up as a new user or %{link:reset password} if an existing user.

I also find it very useful to include It:Helper in rspec/support/utilities.rb

Thanks for your comment. I will improve the README. However, it's not necessary to include the helper into the controller. Instead, just use It.it().