【问题标题】:using Rails I18n in class在课堂上使用 Rails I18n
【发布时间】:2011-06-01 11:20:09
【问题描述】:

我有一个类可以用 Prawn 生成 PDF:

class CustomersReport < Prawn::Document
  def to_pdf
    text "Hello, world"
    render
  end
end

如何在这个课程中使用 Rails I18n?如果我尝试使用translation() 函数,它会为CustomersReport:Class 打印undefined methodtranslation'

我尝试将include ActionView::Helpers::TranslationHelper添加到我的班级,但没有效果。

【问题讨论】:

    标签: ruby-on-rails-3 internationalization


    【解决方案1】:

    使用I18n.t(...)I18n.translate(...)

    【讨论】:

      猜你喜欢
      • 2019-05-13
      • 2015-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-03
      相关资源
      最近更新 更多