What naming conventions do you use when writing i18n yaml files?

73 views
Skip to first unread message

Mohamad El-Husseini

unread,
Apr 27, 2012, 10:18:28 AM4/27/12
to rubyonra...@googlegroups.com
Do you follow naming conventions when writing i18n yaml files? If so, what are they?

For example, say you have a "Save changes" button that PUTs to users_controller.update. What would you call it?

    users.edit.update_button
    users.edit.updatebutton
    users.edit.button_update
    users.edit.save_changes
    etc...

What about flash messages? I have them organized as such now:

    controller.action.flash_success and controller.action.flash_error.

Any thoughts on naming conventions? Dashes? Underscores?

Tim Shaffer

unread,
Apr 27, 2012, 2:55:46 PM4/27/12
to rubyonra...@googlegroups.com
For your first example, Rails already has built-in keys for submit buttons that you can change globally:

en:
  helpers:
    submit:
      create: "Create %{model}"
      update: "Update %{model}"

Or only for a specific model:

en:
  helpers:
    submit:
      post: 
        create: "Create the new post"
        update: "Update existing post"

Those are used automatically when you use <%= f.submit %>

Reply all
Reply to author
Forward
0 new messages