class FastGettext::TranslationRepository::Db
Responsibility:
- provide access to translations in database through a database abstraction Options: :model => Model that represents your keys you can either use the models supplied under db/, extend them or build your own only constraints: key: find_by_key, translations translation: text, locale
Public Class Methods
included(base)
click to toggle source
# File lib/fast_gettext/translation_repository/db.rb, line 59 def self.included(base) puts "you no longer need to include the result of require_models" end
new(name,options={})
click to toggle source
# File lib/fast_gettext/translation_repository/db.rb, line 14 def initialize(name,options={}) @model = options[:model] end
require_models()
click to toggle source
# File lib/fast_gettext/translation_repository/db.rb, line 54 def self.require_models folder = "fast_gettext/translation_repository/db_models" require "#{folder}/translation_key" require "#{folder}/translation_text" Module.new do def self.included(base) puts "you no longer need to include the result of require_models" end end end
seperator()
click to toggle source
# File lib/fast_gettext/translation_repository/db.rb, line 20 def self.seperator;@@seperator;end
seperator=(sep)
click to toggle source
# File lib/fast_gettext/translation_repository/db.rb, line 19 def self.seperator=(sep);@@seperator = sep;end
Public Instance Methods
[](key)
click to toggle source
# File lib/fast_gettext/translation_repository/db.rb, line 38 def [](key) @model.translation(key, FastGettext.locale) end
available_locales()
click to toggle source
# File lib/fast_gettext/translation_repository/db.rb, line 22 def available_locales if @model.respond_to? :available_locales @model.available_locales || [] else [] end end
plural(*args)
click to toggle source
# File lib/fast_gettext/translation_repository/db.rb, line 42 def plural(*args) if translation = @model.translation(args*self.class.seperator, FastGettext.locale) translation.to_s.split(self.class.seperator) else [] end end
pluralisation_rule()
click to toggle source
# File lib/fast_gettext/translation_repository/db.rb, line 30 def pluralisation_rule if @model.respond_to? :pluralsation_rule @model.pluralsation_rule else nil end end
reload()
click to toggle source
# File lib/fast_gettext/translation_repository/db.rb, line 50 def reload true end