class AdLocalize::Interactors::Platforms::ExportAndroidLocaleWording
Constants
- LOCALE_DIRECTORY_CONVENTION
- STRINGS_FILENAME
Public Class Methods
new()
click to toggle source
# 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
Public Instance Methods
call(wording:, locale:, platform_dir:)
click to toggle source
# 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?()
click to toggle source
# File lib/ad_localize/interactors/platforms/export_android_locale_wording.rb, line 26 def should_export_locale_by_locale? true end
Private Instance Methods
compute_output_dir(wording:, locale:, platform_dir:)
click to toggle source
# File lib/ad_localize/interactors/platforms/export_android_locale_wording.rb, line 36 def compute_output_dir(wording:, locale:, platform_dir:) locale_suffix = wording.default_locale?(locale: locale) ? '' : "-#{locale}" platform_dir.join(LOCALE_DIRECTORY_CONVENTION % { locale_suffix: locale_suffix }) end
has_android_wording?(locale_wording:)
click to toggle source
# File lib/ad_localize/interactors/platforms/export_android_locale_wording.rb, line 32 def has_android_wording?(locale_wording:) locale_wording.has_singular_keys? || locale_wording.has_plural_keys? end