Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以根据 Rails 模型关闭 I18n/Globalize3 后备?即有些模型使用后备,有些没有。
是的,可以通过覆盖globalize_fallbacks模型中的方法来实现。以带有翻译标题和内容的帖子模型为例:
globalize_fallbacks
class Post < ActiveRecord::Base translates :title, :content # Disable fallbacks for this model def globalize_fallbacks(locale) [locale] end end
您只需指定请求的语言环境只能回退到自身,无论您的全局配置中定义了什么。