Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 61 lines (34 sloc) 2.697 kb
4a13f0b David Heinemeier Hansson Update readme for Rails 3 and setup stuff
dhh authored
1 Tolk is a Rails 3 engine designed to facilitate the translators doing the dirty work of translating your application to other languages.
be0c96e David Heinemeier Hansson First init
dhh authored
2
ccdc033 Pratik Basic README
lifo authored
3 * Installation & Setup
be0c96e David Heinemeier Hansson First init
dhh authored
4
4a13f0b David Heinemeier Hansson Update readme for Rails 3 and setup stuff
dhh authored
5 To install add the following to your Gemfile:
be0c96e David Heinemeier Hansson First init
dhh authored
6
4a13f0b David Heinemeier Hansson Update readme for Rails 3 and setup stuff
dhh authored
7 gem 'tolk'
be0c96e David Heinemeier Hansson First init
dhh authored
8
4a13f0b David Heinemeier Hansson Update readme for Rails 3 and setup stuff
dhh authored
9 To setup just run:
be0c96e David Heinemeier Hansson First init
dhh authored
10
4a13f0b David Heinemeier Hansson Update readme for Rails 3 and setup stuff
dhh authored
11 $ rake tolk:setup
8675bd0 Pratik Improve README
lifo authored
12
ccdc033 Pratik Basic README
lifo authored
13 * Usage
be0c96e David Heinemeier Hansson First init
dhh authored
14
8e7eb92 Pratik Fix the note about Locale.primary_locale_name in README
lifo authored
15 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 David Heinemeier Hansson First init
dhh authored
16
ccdc033 Pratik Basic README
lifo authored
17 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 David Heinemeier Hansson First init
dhh authored
18
ebd233c Pratik Tolk rake tasks
lifo authored
19 $ rake tolk:sync
ccdc033 Pratik Basic README
lifo authored
20
21 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 David Heinemeier Hansson First init
dhh authored
22
86081dd Pratik Add a note about tolk:import in README
lifo authored
23 If you already have data in your non primary locale files, you will need to import those to Tolk as a one time thing :
24
25 $ rake tolk:import
26
c0c6fe2 Pratik Update the README
lifo authored
27 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 David Heinemeier Hansson First init
dhh authored
28
ebd233c Pratik Tolk rake tasks
lifo authored
29 $ rake tolk:dump_all
be0c96e David Heinemeier Hansson First init
dhh authored
30
6676379 Yaroslav Markin RAILS_ROOT is deprecated, use Rails.root
yaroslav authored
31 This will generate yml files for all non primary locales and put them in #{Rails.root}/config/locales/ directory by default.
ebd233c Pratik Tolk rake tasks
lifo authored
32
33 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 Pratik More README
lifo authored
34
4bafade Pratik Implement authentication mechanism
lifo authored
35 $ script/runner "Tolk::Locale.dump_all('/Users/lifo')"
36
c0c6fe2 Pratik Update the README
lifo authored
37 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
38
4bafade Pratik Implement authentication mechanism
lifo authored
39 * Authentication
40
41 If you want to authenticate users who can access Tolk, you need to provide <tt>Tolk::ApplicationController.authenticator</tt> proc. For example :
42
43 # config/initializers/tolk.rb
44 Tolk::ApplicationController.authenticator = proc {
45 authenticate_or_request_with_http_basic do |user_name, password|
46 user_name == 'translator' && password == 'transpass'
47 end
48 }
49
50 Authenticator proc will be run from a before filter in controller context.
4d16966 Pratik README: Handling blank and non-string values
lifo authored
51
52 * Handling blank and non-string values
53
f3fc2d1 Pratik Update docs for nil value
lifo authored
54 Tolk speaks YAML for non strings values. If you want to enter a nil values, you could just enter '~'. Similarly, for an Array value, you could enter :
4d16966 Pratik README: Handling blank and non-string values
lifo authored
55
56 ---
57 - Sun
58 - Mon
59
60 And Tolk will take care of generating the appropriate entry in the YAML file.
Something went wrong with that request. Please try again.