I've been working on i18n'ing our Rails application and have found
that we started to have lots of similar looking calls to "t
('controller.action.name')" sprinkled everywhere in a very un-DRY way.
Have others come up with a good convention for a namespace for keys to
be translated?
We've started having key structures like:
lang:
controller:
action:
str1: "Page Title"
so for an example blog applications it might be:
en:
posts:
show:
title: "My Blog Post"
We've done something similar for translated strings in models:
en:
user:
name_taken: "This username has been taken"
I want some sensible convention so that I can write a plugin (in-
progress) to make it easy to pull up strings in the context of
models / views / controller. For example, so far it assumes a key
structure so if you are in:
class Posts < ApplicationController
def index
@page_title = t('title') # plugin maps to => I18n.t
('posts.index.title')
end
Does this seem reasonable? Anyone have a better layout?
I'm trying to come up with sensible layout for partials (both shared
partials & within a single controller). I'd appreciate feedback and/or
to hear how others have done it, since we've just begun.
Thanks,
-mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"rails-i18n" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rails-i18n?hl=en
-~----------~----~----~----~------~----~------~--~---