Module: DataMapper::Is::Localizable::ClassMethods
- Defined in:
- lib/dm-is-localizable/is/localizable.rb
Instance Method Summary collapse
-
#available_languages ⇒ Object
list all available languages for the localizable model.
-
#localizable_properties ⇒ Object
returns a list of symbols reflecting all localizable property names of this resource.
-
#nr_of_available_languages ⇒ Object
the number of all available languages for the localizable model.
-
#translations_complete? ⇒ Boolean
checks if all localizable resources are translated in all available languages.
Instance Method Details
#available_languages ⇒ Object
list all available languages for the localizable model
61 62 63 |
# File 'lib/dm-is-localizable/is/localizable.rb', line 61 def available_languages Language.all :id => translation_class.all.map { |t| t.language_id }.uniq end |
#localizable_properties ⇒ Object
returns a list of symbols reflecting all localizable property names of this resource
76 77 78 79 80 81 82 83 |
# File 'lib/dm-is-localizable/is/localizable.rb', line 76 def localizable_properties translation_class.properties.map do |p| p.name end.select do |p| # exclude properties that are'nt localizable p != :id && p != :language_id && p != Extlib::Inflection.foreign_key(self.name).to_sym end end |
#nr_of_available_languages ⇒ Object
the number of all available languages for the localizable model
66 67 68 |
# File 'lib/dm-is-localizable/is/localizable.rb', line 66 def nr_of_available_languages available_languages.size end |
#translations_complete? ⇒ Boolean
checks if all localizable resources are translated in all available languages
71 72 73 |
# File 'lib/dm-is-localizable/is/localizable.rb', line 71 def translations_complete? available_languages.size * all.size == translation_class.all.size end |