Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby Rails上的Java CMS:翻译/本地化博客模块中的字符串_Ruby_Ruby On Rails 3_Localization_Internationalization_Refinerycms - Fatal编程技术网

Ruby Rails上的Java CMS:翻译/本地化博客模块中的字符串

Ruby Rails上的Java CMS:翻译/本地化博客模块中的字符串,ruby,ruby-on-rails-3,localization,internationalization,refinerycms,Ruby,Ruby On Rails 3,Localization,Internationalization,Refinerycms,在炼油厂CMS的博客模块中,我想翻译源代码中的一些字符串。当我覆盖blog模块的_post.html.erb视图时,内部有如下代码: <%= content_tag(:span, "#{t('by', :scope => 'refinery.blog.posts.show')} #{@post.author.username}", :class => "blog_author") if @post.author.present? %> 在applicat

在炼油厂CMS的博客模块中,我想翻译源代码中的一些字符串。当我覆盖blog模块的_post.html.erb视图时,内部有如下代码:

 <%= content_tag(:span, 
   "#{t('by', :scope => 'refinery.blog.posts.show')} #{@post.author.username}",
   :class => "blog_author") if @post.author.present? %>
在application.rb中

在rails控制台中,我得到:

*I18n.locale* => :hr, 
 I18n.translate('hello') => "Pozdrav svima" 
但是,当我启动应用程序时,rails服务器消息中有:

*Parameters: {"locale"=>:en}*
没有翻译工作。。。为什么?

根据 可以根据url设置应用程序区域设置。对于localhost,区域设置为英语。为了改变这一点,可以修改应用程序_controller.rb

class ApplicationController
*Parameters: {"locale"=>:en}*
class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  before_action :set_locale

  def set_locale
    I18n.locale = I18n.default_locale
  end

end