Sha256: 938d011679f6b8005c26bfbbae06f8b627ca375dbb3db7f83fc896d946ac5cbf

Contents?: true

Size: 918 Bytes

Versions: 17

Compression:

Stored size: 918 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|
          @files[locale] = MoFile.new(file)
        end
      end

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

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
grosser-fast_gettext-0.4.0 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.10 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.11 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.12 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.13 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.14 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.15 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.16 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.2 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.3 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.4 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.5 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.7 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.8 lib/fast_gettext/translation_repository/mo.rb
grosser-fast_gettext-0.4.9 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.4.17 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.4.16 lib/fast_gettext/translation_repository/mo.rb