lib/lolita-translation/has_translations.rb in lolita-translation-0.2.7 vs lib/lolita-translation/has_translations.rb in lolita-translation-0.2.8

- old
+ new

@@ -102,12 +102,12 @@ class_inheritable_reader :columns_has_translations if options[:reader] attrs.each do |name| send :define_method, name do - unless I18n.default_locale == I18n.locale - translation = self.translation(I18n.locale) + unless ::I18n.default_locale == ::I18n.locale + translation = self.translation(::I18n.locale) if translation.nil? if has_translations_options[:fallback] (self[name].nil? || self[name].blank?) ? has_translations_options[:nil] : self[name].set_origins(self,name) else has_translations_options[:nil] @@ -145,11 +145,11 @@ } class << self def find_with_translations(*args,&block) - unless I18n.locale == I18n.default_locale + unless ::I18n.locale == ::I18n.default_locale if args && args[0].kind_of?(Hash) args[0][:include] ||=[] args[0][:include] << :translations end end @@ -323,11 +323,11 @@ # a.title # => "LV title" # a.in(:en).title # => "EN title" def in locale - locale.to_sym == I18n.default_locale ? self : find_translation(locale) + locale.to_sym == ::I18n.default_locale ? self : find_translation(locale) end def find_or_build_translation(*args) locale = args.first.to_s build = args.second.present? @@ -337,24 +337,24 @@ def translation(locale) find_translation(locale.to_s) end def all_translations - t = I18n.available_locales.map do |locale| + t = ::I18n.available_locales.map do |locale| [locale, find_or_build_translation(locale)] end ActiveSupport::OrderedHash[t] end def has_translation?(locale) - return true if locale == I18n.default_locale + return true if locale == ::I18n.default_locale find_translation(locale).present? end # if object is new, then nested slaves ar built for all available locales def build_nested_translations - if (I18n.available_locales.size - 1) > self.translations.size - I18n.available_locales.clone.delete_if{|l| l == I18n.default_locale}.each do |l| + if (::I18n.available_locales.size - 1) > self.translations.size + ::I18n.available_locales.clone.delete_if{|l| l == ::I18n.default_locale}.each do |l| options = {:locale => l.to_s} self_adapter = Lolita::DBI::Base.create(self.class) options[self_adapter.reflect_on_association(:translations).klass.master_id] = self.id unless self.new_record? self.translations.build(options) unless self.translations.map(&:locale).include?(l.to_s) end