forked from RaVbaker/tolk
-
Notifications
You must be signed in to change notification settings - Fork 0
Redis-Tolk is a web interface for doing i18n translations packaged as an engine for Rails 2.3 applications, using Redis instead of ActiveRecord
License
alexey/redis-tolk
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
*This is first version that has to be cleaned up and improved, however it works* Redis-Tolk is a Rails engine designed to facilitate the translators doing the dirty work of translating your application to other languages. Its based on original tolk plugin done by David (https://github.com/dhh/tolk/) This plugin will use Redis engine as storage and Ohm plugin for loading objects. For Redis you should use only string/nil values for keys, otherwise you will have incorrect values in the Redis : weekdays: ["Sunday", "Monday", "Thuesday", "Wednesday", "Thursday", "Friday", "Saturday"] in redis become : weekdays=SundayMonday... So you have to simplify yml file : weekdays: - Sunday - Monday ..etc ------------ * Installation & Setup To install : 1) GEMs : $ gem install ohm ya2yaml (use sudo if needed) 2) REDIS : http://jimneath.org/2011/03/24/using-redis-with-ruby-on-rails.html 3) REDIS-TOLK: $ script/plugin install git://github.com/alexey/redis-tolk.git To setup : 1) 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 2) Create new redis namespace and tell to Ohm to what redis db to connect, last line of environment.rb : Ohm.connect :db => 8 #use any index("namespace") that not in use 3) Setup default locale as constant with symbolic link : I18N_LOCALE = :en And you're all set! ------------ * Usage 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. 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. If you already have data in your non primary locale files, you will need to import those to Tolk as a one time thing : $ rake tolk:import 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 : $ 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 http://your_app.com/tolk/locales/de.yml * 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' end } Authenticator proc will be run from a before filter in controller context. * Handling blank and non-string values 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 : --- - Sun - Mon And Tolk will take care of generating the appropriate entry in the YAML file.
About
Redis-Tolk is a web interface for doing i18n translations packaged as an engine for Rails 2.3 applications, using Redis instead of ActiveRecord
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published
Languages
- Ruby 99.7%
- JavaScript 0.3%