title: Extend a module in Rails 3
body: <p>I want to define a function <code>available_translations</code> which lists the translations I have made for my application into the <code>I18n</code> module. </p>
  
  <p>I tried putting the following into the file <code>lib/i18n.rb</code>, but it doesn't work when I try to use it from the rails console:</p>
  
  <pre><code>module I18n
    # Return the translations available for this application.
    def self.available_translations
      languages = []
      Dir.glob(Rails.root.to_s + '/config/locales/*.yml') do |filename|
        if md = filename.match #^.+/(\w+).yml$#
          languages &lt;&lt; md[1]
        end
      end
      languages
    end
  end
  </code></pre>
  
  <p>Console:</p>
  
  <pre><code>ruby-1.9.2-p290 :003 &gt; require Rails.root.to_s + '/lib/i18n.rb'
  =&gt; false
  ruby-1.9.2-p290 :004 &gt; I18n.available_translations
  NoMethodError: undefined method `available_translations' for I18n:Module
  ...
  </code></pre>
  
  <p>Besides solving my concrete problem, I would be very pleased to learn how this whole module thing in Ruby on Rails works because it still confuses me, so I would appreciate links to the docs or source code <em>very much</em>.</p>