Every repository with this icon (
Every repository with this icon (
tree f4320ca2fd35e704c91d52859c006b7127411acb
parent 9b95fd97101bc638f6b91cca81e40a447e209408
| name | age | message | |
|---|---|---|---|
| |
README.textile | ||
| |
Rakefile | ||
| |
init.rb | ||
| |
init.yml | ||
| |
install.rb | ||
| |
lib/ | ||
| |
spec/ | ||
| |
tasks/ | ||
| |
uninstall.rb |
I18nHelper
With this plugin you can pass symbols to all popular Rails helpers and have
them translated. Also provides view_translate() method to translate within
the scope of the controller and action.
Installation
Install this plugin the usual way and add :i18n to your helpers in the
ApplicationController, for example:
Usage
in app/views/posts/index.html.erb:
<%= link_to(:new_post, new_post_path) %>will lookup these translations:
- views.posts.index.new_post
- views.posts.common.new_post
- views.common.new_post
Basically all these helpers do is call view_translate(). The example above
is exactly the same as link_to(vt(:new_post), new_post_path).
Translating existing helpers
To translate helper methods of plugins or your own helpers, you can place a
yaml file i18n_helper.yml in your config directory. The format is like this:
The number after the method name is the index of the argument to be translated.
This is usually 0, but can of course vary. You can specify an array of indexes
if you want.
You can also translate a helper on the spot in code:
I18nHelper.translate_helper(:my_helper, 1, self)The self is the object on which the helper can be found.
Notes
Still beta, needs tests. If you wish to contribute or found a bug, please
send me a message.
On my todo-list is translating certain options too, like the :confirm option in
link_to.
Copyright © 2008 Iain Hecker, released under the MIT license








