0

I want to access the following string from our config/locales/en.yml file in my coffee script page ..

en:
  share_message: "Help our organization."

Following this guide -- http://primegap.net/2011/02/28/rails-quicktip-variables-i18n-localized-strings/, I thought the way to do it was to do

<%= t("share_message") %>

but this results in a

undefined method `t' for #<#<Class:0x00007f97ae3ddd88>:0x00007f97a7b37ae0>

error. What's the proper way to access the string in teh locales file? This is with Ruby on Rails 5.1.

satish
  • 703
  • 5
  • 23
  • 52
  • "in my coffee script page" could you please paste that page? are we talking about a partial? – vzamanillo Apr 19 '18 at 19:50
  • 1
    Possible duplicate of [undefined method \`t' for Admin::FaqsController:Class](https://stackoverflow.com/questions/21878676/undefined-method-t-for-adminfaqscontrollerclass) – Brad Werth Apr 19 '18 at 20:06

2 Answers2

0

You can explicitly call it with class:

<%= I18n.t("share_message") %>

You can read more about internationalization here

0

You can pass it in as a symbol

<%= t(:share_message)%>

remember t() is an aliase of I18n.t().

Thato Sello
  • 61
  • 1
  • 10