简体   繁体   中英

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 actually 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM