Every repository with this icon (
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
README.textile | Fri Jan 23 08:25:41 -0800 2009 | |
| |
Rakefile | Tue Oct 28 07:23:33 -0700 2008 | |
| |
init.rb | Tue Oct 28 13:52:10 -0700 2008 | |
| |
init.yml | Tue Oct 28 09:11:36 -0700 2008 | |
| |
install.rb | Tue Oct 28 07:23:33 -0700 2008 | |
| |
lib/ | Fri Jan 23 08:25:41 -0800 2009 | |
| |
spec/ | Tue Oct 28 07:23:33 -0700 2008 | |
| |
tasks/ | Tue Oct 28 07:23:33 -0700 2008 | |
| |
uninstall.rb | Tue Oct 28 07:23:33 -0700 2008 |
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) %>This will be the same as:
<%= link_to(t(:new_post), new_post_path) %>If the argument is not a symbol, it won’t call t(). In the past this would call some interesting view_translate method, which did some scoping. I moved that part (and improved it) to the Mr. T plugin. Please install that to get all kinds of wonderfull goodies for translating from views.
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







