Search code examples
ruby-on-railsrubyruby-on-rails-4haml

How to use the HAML t() helper in RoR


I'm developing an application with Rails 4 and I want to use the helper t() with HAML, but I can not

Example usage:

=model_name = @article.class.model_name.human
%h1 Create  t(:model_name)

My first line shows me the correct article, but when I use t() it shows me t(:model_name). Thanks.


Solution

  • hope in translational file you have en.yml

    en:
      article: MyArticle
    

    Then

    %h2= t 'article'
    

    if you want dynamically

    %h2= t '#{model_name}'