【问题标题】:Rails how to translate captions on form inputs file_field ( i18n )Rails 如何翻译表单输入 file_field ( i18n ) 上的标题
【发布时间】:2010-11-12 04:32:33
【问题描述】:

我正在为我的应用程序构建翻译,但我不知道如何翻译表单字段的默认标题。

特别是 file_form 标签。默认是生成一个带有标题“选择文件”的按钮和一个说明“未选择文件”的注释

这些翻译存在于 yml 中的什么位置?

【问题讨论】:

    标签: ruby-on-rails-3 internationalization input translation


    【解决方案1】:

    不幸的是, 以及它对用户的显示方式取决于浏览器,不可能有太多机会。

    您可以找到几篇关于设置样式以使其看起来有点不同的文章,但是按钮本身和注释上的文本取决于用户正在运行的浏览器的语言,并且您无法更改它(至少我无法更改)找到)

    【讨论】:

      【解决方案2】:

      你最好使用引导文件上传。下面的代码适用于我的应用程序及其多语言

      = transloadit :image_resize
      -6.times do |index|
        .fileupload.fileupload-new.pull-left{style: "padding-right: 5px;", "data-provides" => "fileupload" }
          .fileupload-new.thumbnail{:style => "width: 130px; height: 130px;"} 
            -if @provider.provider_images.present?
              - if @provider.provider_images["provider_image#{index+1}"].present?
                %img{:id=>"providerimage1", :src => @provider.provider_images["provider_image#{index+1}"][0]}/
          .fileupload-preview.fileupload-exists.thumbnail{:style => "width: 130px; height: 130px;"}
          %div
            %span.btn.btn-file
              %span.fileupload-new{:id => "selectbutton"}
                -if index == 0
                  =t('select_profile_image')  
                -else
                  =t('select_image')              
              %span.fileupload-exists
                -if index == 0
                  =t('select_profile_image')  
                -else
                  =t('select_image')      
              =file_field_tag "provider_image#{index+1}" 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-06-08
        • 2015-04-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-07-05
        相关资源
        最近更新 更多