Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tools for working with ruby/rails i18n


I18n Tools

Tools useful for working with Ruby/Rails I18n. Currently contains only the source parser tool.

I18n Keys Source Parser

(You can always have a look at thor -T for the current list of available Thor commands.)


You need to use Ruby 1.9 because we depend on Ripper2Ruby which requires Ripper. If you happen to know a way to compile/use Ripper for Ruby 1.8.x please let me know.

Also, the library currently expects to find the gems I18n and Ripper2Ruby frozen to vendor/.

You also need Thor to use the command line tool. You might experience problems getting Thor to behave under Ruby 1.9. Please let me know when I can remove this notice ;)


install i18n-tools (should require and install ripper2ruby)
install thor
thor install --as i18n-tools


thor i18n:keys:find KEYS [--index] [--dir=DIR] [--pattern=PATTERN] [--context=N] 
thor i18n:keys:find SEARCH REPLACE [--index] [--dir=DIR] [--pattern=PATTERN] [--context=N] [--verbose]

Key Pattern

foo   - finds all calls to I18n.t with the key 'foo'
foo*  - finds all calls to I18n.t with keys starting with 'foo'
*foo  - finds all calls to I18n.t with keys ending with 'foo'
*foo* - finds all calls to I18n.t with keys containing 'foo'

In most situations it might make sense to also use a dot, as in:
foo.*, *.foo, *.foo.*


    Build and/or use an index. When you use --index for the first time
    an index will be built. On subsequent usages the existing index will
    be used (largely speeding up the command).

    Root directory where files matching the pattern are searched for. If you
    use a saved index this is also the directory where a .i18n/ directory
    will be created for the index file.

    Glob pattern that is used to find

    Output the given number of lines of context before and after occurences.

    Output additional information (e.g. while index being built). (Currently
    not supported)


thor i18n:keys:find foo.* --index --dir=path/to/project --pattern=**/*.{rb,erb} --context=2
thor i18n:keys:find foo.* bar --index --dir=path/to/project --pattern=**/*.{rb,erb} --context=2


If you're using zsh arguments given with a wildcard are expanded to filenames before being passed. So i18n-keys find foo.* won't work. You can either use quotes as in i18n-keys find "foo.*" or turn zsh filename generation off with: unsetopt GLOB.

If you have Ruby 1.9 installed in parallel to 1.8.x you might want to install Thor with the -E option to make the executable wrapper use /usr/bin/env instead of hardcoding the path to your Ruby executable. E.g.:

sudo gem install wycats-thor -E --source=
Something went wrong with that request. Please try again.