I18n in scaffolded controller and views

I know some gems attempt to do this, but I always felt like this should come from the stock templates.

Lots of places like the Show/edit/destroy links

or the flash messages in the scaffold_controller templates:

are not going through i18n.

If you build your site in english and realize afterward that you need to change things, you end up with a massive amount of “boilerplate” work to do.

For the success flash message, I use this function in my controller instead:

Which allow me to set one message per action (the default key) or one per controller/action pair (the “.success” key).

Maybe defaulting to using i18n in scaffolds does not belong directly in rails, but I always felt like it should.

More than willing to do a PR about it, but wasn’t sure if this would be accepted.

3 Likes

I18n always feels to me like a massive amount of work to do upfront when I’m not sure whether I’m going to need it.

1 Like

An optional --with-i18n might be the way to go then. I also have done the boilerplate-i18n-stuff many times and wished it were there already.

The flip side of that is that if you haven’t planned for i18n, backfilling it into an existing application is pretty intense…

2 Likes