Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 65 lines (36 sloc) 2.795 kb
ccdc033 @lifo Basic README
lifo authored
1 Tolk is a Rails engine designed to facilitate the translators doing the dirty work of translating your application to other languages.
be0c96e @dhh First init
authored
2
ccdc033 @lifo Basic README
lifo authored
3 * Installation & Setup
be0c96e @dhh First init
authored
4
ccdc033 @lifo Basic README
lifo authored
5 To install :
be0c96e @dhh First init
authored
6
ccdc033 @lifo Basic README
lifo authored
7 $ script/plugin install git://github.com/dhh/tolk.git
be0c96e @dhh First init
authored
8
ccdc033 @lifo Basic README
lifo authored
9 To setup :
be0c96e @dhh First init
authored
10
8675bd0 @lifo Improve README
lifo authored
11 1) Generate tolk migration and migrate your database :
a586d20 @lifo Add tolk_migration generator
lifo authored
12
13 $ script/generate tolk_migration
14 $ rake db:migrate
be0c96e @dhh First init
authored
15
8675bd0 @lifo Improve README
lifo authored
16 2) Setup Tolk assets by creating a symlink to tolk/public/tolk inside your application's public directory :
17
18 $ cd public
19 $ ln -s ../vendor/plugins/tolk/public/tolk tolk
20
09ba44b @lifo Add a note about will_paginate in the README file
lifo authored
21 3) Make sure you have the latest will_paginate gem installed :
22
23 $ gem install will_paginate
24
8675bd0 @lifo Improve README
lifo authored
25 And you're all set!
26
ccdc033 @lifo Basic README
lifo authored
27 * Usage
be0c96e @dhh First init
authored
28
8e7eb92 @lifo Fix the note about Locale.primary_locale_name in README
lifo authored
29 Tolk treats I18n.default_locale as the master source of strings to be translated. If you want the master source to be different from I18n.default_locale, you can override it by setting Tolk::Locale.primary_locale_name. Developers are expected to make all the changes to the master locale file ( en.yml by default ) and treat all the other locale.yml files as readonly files.
be0c96e @dhh First init
authored
30
ccdc033 @lifo Basic README
lifo authored
31 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 :
be0c96e @dhh First init
authored
32
ebd233c @lifo Tolk rake tasks
lifo authored
33 $ rake tolk:sync
ccdc033 @lifo Basic README
lifo authored
34
35 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.
be0c96e @dhh First init
authored
36
86081dd @lifo Add a note about tolk:import in README
lifo authored
37 If you already have data in your non primary locale files, you will need to import those to Tolk as a one time thing :
38
39 $ rake tolk:import
40
c0c6fe2 @lifo Update the README
lifo authored
41 Upon visiting http://your_app.com/tolk - 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 :
be0c96e @dhh First init
authored
42
ebd233c @lifo Tolk rake tasks
lifo authored
43 $ rake tolk:dump_all
be0c96e @dhh First init
authored
44
ebd233c @lifo Tolk rake tasks
lifo authored
45 This will generate yml files for all non primary locales and put them in RAILS_ROOT/config/locales/ directory by default.
46
47 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 :
6b8bd68 @lifo More README
lifo authored
48
4bafade @lifo Implement authentication mechanism
lifo authored
49 $ script/runner "Tolk::Locale.dump_all('/Users/lifo')"
50
c0c6fe2 @lifo Update the README
lifo authored
51 You can even download the yml file using Tolk web interface by appending '.yml' to the locale url. E.g http://your_app.com/tolk/locales/de.yml
52
4bafade @lifo Implement authentication mechanism
lifo authored
53 * Authentication
54
55 If you want to authenticate users who can access Tolk, you need to provide <tt>Tolk::ApplicationController.authenticator</tt> proc. For example :
56
57 # config/initializers/tolk.rb
58 Tolk::ApplicationController.authenticator = proc {
59 authenticate_or_request_with_http_basic do |user_name, password|
60 user_name == 'translator' && password == 'transpass'
61 end
62 }
63
64 Authenticator proc will be run from a before filter in controller context.
Something went wrong with that request. Please try again.