Class: AndroidWriter
- Inherits:
-
Object
- Object
- AndroidWriter
- Defined in:
- lib/localio/writers/android_writer.rb
Class Method Summary collapse
- .android_key_formatter(key) ⇒ Object
- .android_parsing(term) ⇒ Object
- .write(languages, terms, path, formatter, options) ⇒ Object
Class Method Details
.android_key_formatter(key) ⇒ Object
35 36 37 |
# File 'lib/localio/writers/android_writer.rb', line 35 def self.android_key_formatter(key) key.space_to_underscore.strip_tag.downcase end |
.android_parsing(term) ⇒ Object
39 40 41 |
# File 'lib/localio/writers/android_writer.rb', line 39 def self.android_parsing(term) term.gsub('& ','& ').gsub('...', '…').gsub('%@', '%s') end |
.write(languages, terms, path, formatter, options) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/localio/writers/android_writer.rb', line 8 def self.write(languages, terms, path, formatter, ) puts 'Writing Android translations...' default_language = [:default_language] languages.keys.each do |lang| output_path = File.join(path,"values-#{lang}/") output_path = File.join(path,'values/') if default_language == lang # We have now to iterate all the terms for the current language, extract them, and store them into a new array segments = SegmentsListHolder.new lang terms.each do |term| key = Formatter.format(term.keyword, formatter, method(:android_key_formatter)) translation = android_parsing term.values[lang] segment = Segment.new(key, translation, lang) segment.key = nil if term.is_comment? segments.segments << segment end TemplateHandler.process_template 'android_localizable.erb', output_path, 'strings.xml', segments puts " > #{lang.yellow}" end end |