ruby simple_form翻译查找

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby simple_form翻译查找相关的知识,希望对你有一定的参考价值。

module SimpleForm
  class FormBuilder
    # The controller name to be used in lookup.
    def lookup_controller #:nodoc:
      @lookup_controller ||= begin
        controller = template.controller && template.controller_name
        return unless controller
        controller = controller.to_s
      end
    end
  end
end
module SimpleForm
  module Inputs
    class Base
      delegate :lookup_controller, to: :@builder

      def translate_from_namespace(namespace, default = '')
        model_names = lookup_model_names.dup
        lookups     = []

        while !model_names.empty?
          joined_model_names = model_names.join(".")
          model_names.shift

          lookups << :"#{joined_model_names}.#{lookup_controller}.#{lookup_action}.#{reflection_or_attribute_name}"
          lookups << :"#{joined_model_names}.#{lookup_controller}.#{lookup_action}.#{reflection_or_attribute_name}_html"
          
          lookups << :"#{joined_model_names}.#{lookup_action}.#{reflection_or_attribute_name}"
          lookups << :"#{joined_model_names}.#{lookup_action}.#{reflection_or_attribute_name}_html"
          lookups << :"#{joined_model_names}.#{reflection_or_attribute_name}"
          lookups << :"#{joined_model_names}.#{reflection_or_attribute_name}_html"
        end
        lookups << :"defaults.#{lookup_action}.#{reflection_or_attribute_name}"
        lookups << :"defaults.#{lookup_action}.#{reflection_or_attribute_name}_html"
        lookups << :"defaults.#{reflection_or_attribute_name}"
        lookups << :"defaults.#{reflection_or_attribute_name}_html"
        lookups << default

        t(lookups.shift, scope: :"#{i18n_scope}.#{namespace}", default: lookups).presence
      end
    end
  end
end

以上是关于ruby simple_form翻译查找的主要内容,如果未能解决你的问题,请参考以下文章

ruby acts_as_taggable_on + simple_form + select2

如何在 simple_form 中使用占位符而不是标签?

CKEditor的第二个实例没有保存到db | Ruby on Rails

ruby 中的 Mandrill 验证,在 php 和 ruby​​ 之间的翻译中丢失

simple_form: 禁用表单而不添加 disabled: true 或 readonly: true 到每个输入

ruby 红宝石的翻译