小编u26*_*622的帖子

国际化Flex应用程序的最佳实践?

我正在研究国际化我正在开发的Flex应用程序,我很好奇是否有任何最佳实践或建议.

谷歌搜索这些信息导致一些小文章和博客文章,每个文章都以不同的方式做,并且优点和缺点并不十分清楚.

编辑缩小范围:

  • 需要仅支持两种语言(en_CA和fr_CA)
  • 需要能够在运行时切换

apache-flex actionscript internationalization

5
推荐指数
1
解决办法
2476
查看次数

Rails路由:为路径助手提供默认值

有没有办法为url/path助手提供默认值?

我有一个可选的范围环绕我的所有路线:

#config/routes.rb
Foo::Application.routes.draw do

  scope "(:current_brand)", :constraints => { :current_brand => /(foo)|(bar)/ } do
    # ... all other routes go here
  end

end
Run Code Online (Sandbox Code Playgroud)

我希望用户能够使用以下URL访问该网站:

/foo/some-place
/bar/some-place
/some-place
Run Code Online (Sandbox Code Playgroud)

为了方便起见,我设置了一个@current_brand在我的ApplicationController:

# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  before_filter :set_brand

  def set_brand                                                                 
    if params.has_key?(:current_brand)                                          
      @current_brand = Brand.find_by_slug(params[:current_brand])               
    else                                                                        
      @current_brand = Brand.find_by_slug('blah')
    end
  end

 end
Run Code Online (Sandbox Code Playgroud)

到目前为止一切都那么好,但是现在我必须修改all *_path*_url调用包含:current_brand参数,即使它是可选的.这真是丑陋,IMO.

有什么方法可以让路径助手自动接听@current_brand吗?

或者也许是一种更好的方法来定义范围routes.rb

ruby routes ruby-on-rails-3

5
推荐指数
2
解决办法
2318
查看次数