Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.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 on rails Rails I18n默认语言的奇怪翻译行为_Ruby On Rails_Ruby_Localization_Internationalization - Fatal编程技术网

Ruby on rails Rails I18n默认语言的奇怪翻译行为

Ruby on rails Rails I18n默认语言的奇怪翻译行为,ruby-on-rails,ruby,localization,internationalization,Ruby On Rails,Ruby,Localization,Internationalization,我第一次使用i18ngem。我正在创建一个网站使用两种语言(英语和孟加拉语)。所以我根据i18napi做了所有的事情。现在一切正常,只有一个例外。我的默认操作(或者你可以说root:to=>My_default_options)在翻译方面有一些问题。我默认的i18n语言是英语。但是默认布局(application.html.erb)中的文本在此操作中默认翻译为孟加拉语。我只重复默认布局中的部分。该操作的视图文件中的其他文本可以很好地进行翻译。另一方面,来自应用程序默认布局的文本可以很好地翻译成英

我第一次使用i18ngem。我正在创建一个网站使用两种语言(英语和孟加拉语)。所以我根据i18napi做了所有的事情。现在一切正常,只有一个例外。我的默认操作(或者你可以说
root:to=>My_default_options
)在翻译方面有一些问题。我默认的i18n语言是英语。但是默认布局(
application.html.erb
)中的文本在此操作中默认翻译为孟加拉语。我只重复默认布局中的部分。该操作的视图文件中的其他文本可以很好地进行翻译。另一方面,来自应用程序默认布局的文本可以很好地翻译成英语和孟加拉语。问题只发生在我的默认操作中

虽然这是一个复杂的问题,我已经上传了我的完整的源代码。(警告:应用程序未完成,因此可能无法正常工作)

我不确定哪些文件是必要的张贴在这里。我在微博控制器中遇到了这个问题。在“新”行动中。给你

class MicroblogsController < ApplicationController
  before_filter :auth, :only => [:up, :down] 
  before_filter :set_locale

  def new
    @text = Microblog.new
    @all = all.paginate(:page => params[:page], :per_page => 5)
    @top = Microblog.top_rated.paginate(:page => params[:page], :per_page => 5)
  end

  def create
    @text = Microblog.new(params[:text])
    if Captcha::valid?(session,params)
      if @text.save
        flash[:notice] = "DONE!"
        redirect_to( @text)
      else
        #redirect_to(  :action => 'new' )
        render 'new'
      end
    else
      flash[:notice] = "Wrong Answer. Try Again!"
      redirect_to :back 
    end

  end

  def show
    @text = Microblog.find(params[:id])
    @com = @text.comments.sorted.paginate(:page => params[:page], :per_page => 5)
    @rating = (@text.up - @text.down)
  end


  def up
    @text = Microblog.find(params[:id])
    @text.update_attributes(params[@text.up += 1])
    @text.update_attributes(params[@text.rate += 1])

    @a.push(@text.id)

    session[:token] = @a
    if @a.size > 5
        @a.delete_at(0)
    end

    redirect_to( :action => 'show', :id => @text.id)
  end

  def down


    @text.update_attributes(params[@text.down += 1])
    @text.update_attributes(params[@text.rate -= 1])

    @a.push(@text.id)
    session[:token] = @a
    if @a.size > 5
        @a.delete_at(0)
    end
    redirect_to( :action => 'show', :id => @text.id)
  end


    private

      def auth
            @text = Microblog.find(params[:id])
            @a = session[:token].to_a

            if @a.include?(@text.id)
                redirect_to( :action => 'show', :id => @text.id)
                return false
            else
                return true
            end
      end



end
config.application.rb中的我的i18n配置

config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
config.i18n.default_locale = :'en'
下面是view/layouts/application.html.erb中的行。这些是我遇到问题的线路

<li><%= link_to("#{ t :Home}", :action => 'new') %></li>
    <%= I18n.locale %> (to see the value of i18n)
  • “新建”)%%>
  • (查看i18n的值)

    此问题仅在呈现微博/新操作时发生。文本“:Home”总是翻译成孟加拉语,并显示i18n变量的值为bn(孟加拉语)。但是,其他部分/VIEW/MyBug/Ne.HTML.Erb翻译为

    请考虑提供您认为相关的代码部分。这个问题不能这样回答。添加了,但不确定这些是必要的代码
    <li><%= link_to("#{ t :Home}", :action => 'new') %></li>
        <%= I18n.locale %> (to see the value of i18n)