Rails public/404.html 原来支持 I18n

bastengao · June 15, 2016 · Last by bastengao replied at June 19, 2016 · 12043 hits

以前都是修改 public/404.html 默认的内容为中文,看了 Rails 的源代码才发现是支持 I18n 的,源代码

想支持中文只需要添加 public/xxx.zh-CN.html 就可以了,前提是配置了 config.i18n.default_locale = :'zh-CN'

public/404.zh-CN.html
public/500.zh-CH.html

可以捕获 404 render view, 这样比较比较好统一 layout

手动鲁了个 gem https://github.com/bastengao/whats-wrong , 方便生成错误页面。

You need to Sign in before reply, if you don't have an account, please Sign up first.