开发者

Locales directory structure for Rails 3

So I see here that the suggested structure for the locales (internationalization) in Rails 3 is based on a similar separation of files used for the models and views directories (see 3.4 Organization of Locale Files on the page).

I have 2 questions:

1) For notices used in the controller - for example, "Your record was added successfully" during a redirect, is the intention that there is a controller directory under locales as well? Or should I just use the default en.yml file in the root locales directory and have something like:

en:
  notices:
    create_success: "Your record was added successfully."
    update_success: "Your record was updated successfully."

This way all notices are in the same file.

2) Based on the convenience thought in some way I actuall开发者_StackOverflow中文版y would prefer all translations in a single file since it's easier/quicker to deal with and find and then more items could potentially be shared. Is there some reason to keep them separated in a similar directory structure to the models and view? - is this due to performance and loading of the files possibly?


If having a separate directory for flash messages and such seems reasonable to you, then go for it. The examples given in the guides are just as it says, examples. Organise them in whatever way makes sense to you.

Same goes for keeping it all in one file. It'll work just the same and the only reason it's suggested to consider breaking it up is because it can become hard to manage. But if you want to do it that way, then do! :) You can always split it up later if you change your mind.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜