Sha256: 4845460dfec775c92333371847d25fc6325a7e2b6f4d4c598e5c82076b688e17

Contents?: true

Size: 903 Bytes

Versions: 15

Compression:

Stored size: 903 Bytes

Contents

require 'fast_gettext/translation_repository/base'
module FastGettext
  module TranslationRepository
     # Responsibility:
    #  - find and store mo files
    #  - provide access to translations in mo files
    class Mo < Base
      def initialize(name,options={})
        find_and_store_files(name,options)
        super
      end

      def available_locales
        @files.keys
      end

      def pluralisation_rule
        current_translations.pluralisation_rule
      end

      protected

      def find_and_store_files(name,options)
        # parse all .mo files with the right name, that sit in locale/LC_MESSAGES folders
        find_files_in_locale_folders(File.join('LC_MESSAGES',"#{name}.mo"), options[:path]) do |locale,file|
          MoFile.new(file)
        end
      end

      def current_translations
        @files[FastGettext.locale] || MoFile.empty
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fast_gettext-0.7.0 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.12 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.11 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.10 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.9 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.8 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.7 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.6 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.5 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.4 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.3 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.2 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.1 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.6.0 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.5.13 lib/fast_gettext/translation_repository/mo.rb