Class: AdLocalize::Platform::AndroidFormatter
- Inherits:
-
PlatformFormatter
- Object
- PlatformFormatter
- AdLocalize::Platform::AndroidFormatter
- Defined in:
- lib/ad_localize/platform/android_formatter.rb
Constant Summary
Constants inherited from PlatformFormatter
PlatformFormatter::OPTIONS, PlatformFormatter::PLURAL_KEY_SYMBOL, PlatformFormatter::SINGULAR_KEY_SYMBOL
Instance Attribute Summary
Attributes inherited from PlatformFormatter
#default_locale, #output_path, #platform_dir
Instance Method Summary collapse
- #export(locale, data, export_extension = nil, substitution_format = nil) ⇒ Object
- #platform ⇒ Object
Methods inherited from PlatformFormatter
Constructor Details
This class inherits a constructor from AdLocalize::Platform::PlatformFormatter
Instance Method Details
#export(locale, data, export_extension = nil, substitution_format = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ad_localize/platform/android_formatter.rb', line 7 def export(locale, data, export_extension = nil, substitution_format = nil) locale = locale.to_sym export_dir_suffix = (locale == default_locale) ? "" : "-#{locale.downcase}" create_locale_dir(export_dir_suffix) xml_doc = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml| xml.resources { data.each do |key, wording| singular_wording = wording.dig(locale, AdLocalize::Constant::SINGULAR_KEY_SYMBOL) add_singular_wording_to_xml(key, singular_wording, xml) unless singular_wording.blank? plural_wording = wording.dig(locale, AdLocalize::Constant::PLURAL_KEY_SYMBOL) add_plural_wording_to_xml(key, plural_wording, xml) unless plural_wording.blank? end } end export_dir(export_dir_suffix).join(AdLocalize::Constant::ANDROID_EXPORT_FILENAME).open("w") do |file| file.puts xml_doc.to_xml(indent: 4) end AdLocalize::LOGGER.log(:debug, :black, "Android [#{locale}] ---> DONE!") end |
#platform ⇒ Object
3 4 5 |
# File 'lib/ad_localize/platform/android_formatter.rb', line 3 def platform :android end |