Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: ebd233c6ae
Fetching contributors…

Cannot retrieve contributors at this time

61 lines (34 sloc) 2.46 KB
Tolk is a Rails engine designed to facilitate the translators doing the dirty work of translating your application to other languages.
* Installation & Setup
To install :
$ script/plugin install git://
To setup :
1) Generate tolk migration and migrate your database :
$ script/generate tolk_migration
$ rake db:migrate
2) Setup Tolk assets by creating a symlink to tolk/public/tolk inside your application's public directory :
$ cd public
$ ln -s ../vendor/plugins/tolk/public/tolk tolk
3) Make sure you have the latest will_paginate gem installed :
$ gem install will_paginate
And you're all set!
* Usage
Tolk treats <tt>Tolk::Locale.primary_locale_name</tt> as the main source of strings to be translated. Developers are expected to make all the changes to that file ( en.yml in our case ) and treat all the other locale.yml files as readonly files.
As tolk stores all the keys and translated strings in the database, you need to ask Tolk to update it's database from the primary yml file :
$ rake tolk:sync
The above will fetch all the new keys from en.yml and put them in the database. Additionally, it'll also get rid of the deleted keys from the database and reflect updated translations - if any.
Upon visiting - you will be presented with different options like creating new locale or providing translations for the existing locales. Once done with translating all the pending strings, you are can write back the new locales to filesystem :
$ rake tolk:dump_all
This will generate yml files for all non primary locales and put them in RAILS_ROOT/config/locales/ directory by default.
You can use the dump_all method defined in Tolk::Locale directly and pass directory path as the argument if you want the generated files to be at a different location :
$ script/runner "Tolk::Locale.dump_all('/Users/lifo')"
You can even download the yml file using Tolk web interface by appending '.yml' to the locale url. E.g
* Authentication
If you want to authenticate users who can access Tolk, you need to provide <tt>Tolk::ApplicationController.authenticator</tt> proc. For example :
# config/initializers/tolk.rb
Tolk::ApplicationController.authenticator = proc {
authenticate_or_request_with_http_basic do |user_name, password|
user_name == 'translator' && password == 'transpass'
Authenticator proc will be run from a before filter in controller context.
Jump to Line
Something went wrong with that request. Please try again.