Class: AdLocalize::Interactors::Platforms::ExportAndroidLocaleWording

Inherits:
Object
  • Object
show all
Defined in:
lib/ad_localize/interactors/platforms/export_android_locale_wording.rb

Constant Summary collapse

STRINGS_FILENAME =
'strings.xml'.freeze
LOCALE_DIRECTORY_CONVENTION =
"values%{locale_suffix}".freeze

Instance Method Summary collapse

Constructor Details

#initializeExportAndroidLocaleWording

Returns a new instance of ExportAndroidLocaleWording.



8
9
10
11
# File 'lib/ad_localize/interactors/platforms/export_android_locale_wording.rb', line 8

def initialize
  @strings_serializer = Serializers::StringsSerializer.new
  @file_system_repository = Repositories::FileSystemRepository.new
end

Instance Method Details

#call(wording:, locale:, platform_dir:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ad_localize/interactors/platforms/export_android_locale_wording.rb', line 13

def call(wording:, locale:, platform_dir:)
  LOGGER.debug("Starting export Android wording for locale #{locale}")
  locale_wording = wording.translations_for(locale: locale)
  return unless has_android_wording?(locale_wording: locale_wording)

  output_dir = compute_output_dir(wording: wording, locale: locale, platform_dir: platform_dir)
  @file_system_repository.create_directory(path: output_dir)

  content = @strings_serializer.render(locale_wording: locale_wording)
  @file_system_repository.write(content: content, path: output_dir.join(STRINGS_FILENAME))
  LOGGER.debug("#{STRINGS_FILENAME} done !")
end

#should_export_locale_by_locale?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/ad_localize/interactors/platforms/export_android_locale_wording.rb', line 26

def should_export_locale_by_locale?
  true
end