Sha256: cc516125cf7731dd7eda3019c16fe48f7a748b22328c75d72fdfa890f64ae8e7

Contents?: true

Size: 963 Bytes

Versions: 7

Compression:

Stored size: 963 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={})
        super
        reload
      end

      def available_locales
        @files.keys
      end

      def pluralisation_rule
        current_translations.pluralisation_rule
      end

      def reload
        find_and_store_files(@name, @options)
        super
      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

7 entries across 7 versions & 1 rubygems

Version Path
fast_gettext-1.0.0 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.9.2 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.9.1 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.9.0 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.8.1 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.8.0 lib/fast_gettext/translation_repository/mo.rb
fast_gettext-0.7.1 lib/fast_gettext/translation_repository/mo.rb