Class: ShipEasyI18n::Rails::LabelFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/rails/label_fetcher.rb

Constant Summary collapse

MANIFEST_KEY_PREFIX =
"i18n:manifest:"
LABEL_KEY_PREFIX =
"i18n:label:"

Instance Method Summary collapse

Constructor Details

#initialize(config = ShipEasyI18n.configuration) ⇒ LabelFetcher

Returns a new instance of LabelFetcher.



12
13
14
# File 'lib/i18n/rails/label_fetcher.rb', line 12

def initialize(config = ShipEasyI18n.configuration)
  @config = config
end

Instance Method Details

#fetch(profile: @config.profile, chunk: @config.default_chunk) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/i18n/rails/label_fetcher.rb', line 16

def fetch(profile: @config.profile, chunk: @config.default_chunk)
  manifest = fetch_manifest(profile)
  return nil unless manifest

  file_url = manifest[chunk]
  return nil unless file_url

  fetch_label_file(file_url)
rescue => e
  ::Rails.logger.warn("[ShipEasyI18n] Failed to fetch labels: #{e.message}") if defined?(::Rails)
  nil
end