Module Gibberish::Localize
In: lib/gibberish_db.rb

Methods

Public Instance methods

[Source]

     # File lib/gibberish_db.rb, line 128
128:     def create_translation(string, key, *args)
129:       format = args.first.delete(:format) if args.first.is_a?(Hash)
130:       format ||= :inline
131:       returning Translation.create(:value => string,
132:                                   :key => key.to_s,
133:                                   :language_id => Language.find_cached_by_name(current_language).id,
134:                                   :format => format.to_s) do |translation|
135:         RAILS_DEFAULT_LOGGER.warn "Failed to create translation: #{translation.errors.full_messages}" unless translation.errors.empty?
136:       end
137:     end

[Source]

     # File lib/gibberish_db.rb, line 122
122:     def load_languages_with_db!
123:       Language.find(:all).each do |lang|
124:         @@languages[lang.name.to_sym] = Translator.new(lang)
125:       end
126:     end

[Source]

     # File lib/gibberish_db.rb, line 138
138:     def translate_with_db(string, key, *args)
139:       return if reserved_keys.include? key
140:       target = translations[key] || create_translation(string,key,*args)
141:       arguments = extract_arguments(args)
142:       interpolate_string(target.dup, *arguments.dup)
143:     end

[Validate]