Sha256: 73958b47877c4906ed136462437381a0ac80550702cade51df105b68a95fc170

Contents?: true

Size: 824 Bytes

Versions: 3

Compression:

Stored size: 824 Bytes

Contents

# frozen_string_literal: true

require_relative "data/service"
require_relative "data/checker"
require_relative "data/processor"
require_relative "data/missing_translations"

module Localer
  # Stores translations and provides
  # check methods
  class Data
    extend Dry::Initializer
    param :source, default: -> { {} }
    param :config, default: -> { Localer.config }

    attr_reader :translations, :locales

    def initialize(*args)
      super
      @locales, @translations = Processor.call(source, config)
    end

    def complete?
      Checker.call(self)
    end

    def missing_translations
      MissingTranslations.call(self)
    end

    def each
      @translations.each do |key, value|
        @locales.each do |locale|
          yield locale, key, value[locale]
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
localer-0.2.0 lib/localer/data.rb
localer-0.1.1 lib/localer/data.rb
localer-0.1.0 lib/localer/data.rb