class I18n::Backend::Weeler
I18n
backend by weeler for storing translations in database and caching.
It implements storing all translation in Translation
active record moduel table. When application is running, it stores translation in cache for better performance.
Also this backend provides extra moduls:
-
HTML checher, for storing html translations.
-
exporter - for export all translations in xlsx
-
importer - for importing all translations
-
Dedupe
- you should use if you find duplicated keys
Weeler
model used to store locks
This model expects a table like the following to be already set up in your the database:
def self.up
create_table :weeler_locks do |t| t.string :name, :limit => 40 t.timestamps end add_index :weeler_locks, :name, :unique => true
end
def self.down
remove_index :weeler_locks, :column => :name drop_table :weeler_locks
end
Weeler
model used to store actual translations to the database.
This model expects a table like the following to be already set up in your the database:
create_table :translations do |t| t.string :locale t.string :key t.text :value t.text :interpolations t.boolean :is_proc, :default => false end
This model supports to named scopes :locale and :lookup. The :locale scope simply adds a condition for a given locale:
I18n::Backend::Weeler::Translation.locale(:en).all # => all translation records that belong to the :en locale
The :lookup scope adds a condition for looking up all translations that either start with the given keys (joined by an optionally given separator or I18n.default_separator) or that exactly have this key.
# with translations present for :"foo.bar" and :"foo.baz" I18n::Backend::Weeler::Translation.lookup(:foo) # => an array with both translation records :"foo.bar" and :"foo.baz" I18n::Backend::Weeler::Translation.lookup([:foo, :bar]) I18n::Backend::Weeler::Translation.lookup(:"foo.bar") # => an array with the translation record :"foo.bar"
When the StoreProcs module was mixed into this model then Procs will be stored to the database as Ruby code and evaluated when :value is called.
Translation = I18n::Backend::Weeler::Translation Translation.create \ :locale => 'en' :key => 'foo' :value => lambda { |key, options| 'FOO' } Translation.find_by_locale_and_key('en', 'foo').value # => 'FOO'
Weeler
model used to store translation key usage statistics
This model expects a table like the following to be already set up in your the database:
create_table :weeler_translation_stats do |t| t.string :key t.integer :usage_count, default: 0 end
Constants
- PLURAL_KEYS