Skip to content
Newer
Older
100644 53 lines (30 sloc) 2.29 KB
ccdc033 @lifo Basic README
lifo authored Apr 7, 2010
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 Oct 29, 2008
2
ccdc033 @lifo Basic README
lifo authored Apr 7, 2010
3 * Installation & Setup
be0c96e @dhh First init
authored Oct 29, 2008
4
ccdc033 @lifo Basic README
lifo authored Apr 7, 2010
5 To install :
be0c96e @dhh First init
authored Oct 29, 2008
6
ccdc033 @lifo Basic README
lifo authored Apr 7, 2010
7 $ script/plugin install git://github.com/dhh/tolk.git
be0c96e @dhh First init
authored Oct 29, 2008
8
ccdc033 @lifo Basic README
lifo authored Apr 7, 2010
9 To setup :
be0c96e @dhh First init
authored Oct 29, 2008
10
ccdc033 @lifo Basic README
lifo authored Apr 7, 2010
11 1) Define the primary locale inside your application's configuration file :
be0c96e @dhh First init
authored Oct 29, 2008
12
ccdc033 @lifo Basic README
lifo authored Apr 7, 2010
13 # environment.rb
ef27fa6 @lifo Fix the README file w/ namespace changes
lifo authored Apr 7, 2010
14 Tolk::Locale.primary_locale_name = 'en'
be0c96e @dhh First init
authored Oct 29, 2008
15
a586d20 @lifo Add tolk_migration generator
lifo authored Apr 7, 2010
16 2) Generate tolk migration and migrate your database :
17
18 $ script/generate tolk_migration
19 $ rake db:migrate
be0c96e @dhh First init
authored Oct 29, 2008
20
ccdc033 @lifo Basic README
lifo authored Apr 7, 2010
21 * Usage
be0c96e @dhh First init
authored Oct 29, 2008
22
4bafade @lifo Implement authentication mechanism
lifo authored Apr 7, 2010
23 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.
be0c96e @dhh First init
authored Oct 29, 2008
24
ccdc033 @lifo Basic README
lifo authored Apr 7, 2010
25 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 Oct 29, 2008
26
ef27fa6 @lifo Fix the README file w/ namespace changes
lifo authored Apr 7, 2010
27 $ script/runner 'Tolk::Locale.sync!'
ccdc033 @lifo Basic README
lifo authored Apr 7, 2010
28
29 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 Oct 29, 2008
30
c0c6fe2 @lifo Update the README
lifo authored Apr 8, 2010
31 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 Oct 29, 2008
32
ef27fa6 @lifo Fix the README file w/ namespace changes
lifo authored Apr 7, 2010
33 $ script/runner 'Tolk::Locale.dump_all'
be0c96e @dhh First init
authored Oct 29, 2008
34
6b8bd68 @lifo More README
lifo authored Apr 7, 2010
35 This will generate yml files for all non primary locales and put them in RAILS_ROOT/config/locales/ directory by default. You can pass directory path as the argument if you want the generated files to be at a different location :
36
4bafade @lifo Implement authentication mechanism
lifo authored Apr 7, 2010
37 $ script/runner "Tolk::Locale.dump_all('/Users/lifo')"
38
c0c6fe2 @lifo Update the README
lifo authored Apr 8, 2010
39 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
40
4bafade @lifo Implement authentication mechanism
lifo authored Apr 7, 2010
41 * Authentication
42
43 If you want to authenticate users who can access Tolk, you need to provide <tt>Tolk::ApplicationController.authenticator</tt> proc. For example :
44
45 # config/initializers/tolk.rb
46 Tolk::ApplicationController.authenticator = proc {
47 authenticate_or_request_with_http_basic do |user_name, password|
48 user_name == 'translator' && password == 'transpass'
49 end
50 }
51
52 Authenticator proc will be run from a before filter in controller context.
Something went wrong with that request. Please try again.