Module: RemoteTranslationLoader

Defined in:
lib/remote_translation_loader.rb,
lib/remote_translation_loader/errors.rb,
lib/remote_translation_loader/loader.rb,
lib/remote_translation_loader/railtie.rb,
lib/remote_translation_loader/version.rb,
lib/remote_translation_loader/configuration.rb,
lib/remote_translation_loader/source_resolver.rb,
lib/remote_translation_loader/fetchers/s3_fetcher.rb,
lib/remote_translation_loader/fetchers/base_fetcher.rb,
lib/remote_translation_loader/fetchers/file_fetcher.rb,
lib/remote_translation_loader/fetchers/http_fetcher.rb,
sig/remote_translation_loader.rbs

Defined Under Namespace

Modules: Fetchers Classes: Configuration, Error, FetchError, Loader, ParseError, Railtie, SourceResolver, ValidationError

Constant Summary collapse

VERSION =

Returns:

  • (String)
"2.0.0"

Class Method Summary collapse

Class Method Details

.configurationObject



20
21
22
# File 'lib/remote_translation_loader.rb', line 20

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



24
25
26
27
# File 'lib/remote_translation_loader.rb', line 24

def configure
  yield(configuration) if block_given?
  configuration
end

.load(sources, **options) ⇒ Object

One-liner convenience: RemoteTranslationLoader.load(["en.yml", "https://.../fr.yml"])



16
17
18
# File 'lib/remote_translation_loader.rb', line 16

def load(sources, **options)
  Loader.new(sources).fetch_and_load(**options)
end

.load_configured_translationsObject

Used by the Railtie to fetch+load whatever was set via .configure.



30
31
32
33
34
35
36
# File 'lib/remote_translation_loader.rb', line 30

def load_configured_translations
  config = configuration
  return if config.sources.empty?

  Loader.new(config.sources, logger: config.logger)
        .fetch_and_load(dry_run: config.dry_run, namespace: config.namespace)
end