Class: Locraft::XMLStringsGenerator

Inherits:
StringsGenerator show all
Defined in:
lib/locraft/generators/xml_strings_generator.rb

Instance Method Summary collapse

Methods inherited from StringsGenerator

#generate, #strings_file, #strings_file_content, #valid?, #valid_localization?

Methods inherited from Generator

#generate, #initialize, #valid?

Constructor Details

This class inherits a constructor from Locraft::Generator

Instance Method Details

#broadcast_file_generation(f) ⇒ Object



21
22
23
# File 'lib/locraft/generators/xml_strings_generator.rb', line 21

def broadcast_file_generation(f)
  puts "xml strings file generated: [#{f}]"
end

#destination_dir_for(lang, lang_code) ⇒ Object



9
10
11
12
# File 'lib/locraft/generators/xml_strings_generator.rb', line 9

def destination_dir_for(lang, lang_code)
  comp = @config.default_lang == lang ? 'values' : "values-#{lang_code}"
  "#{@config.relative_strings_destination}/#{comp}"
end

#file_templateObject



5
6
7
# File 'lib/locraft/generators/xml_strings_generator.rb', line 5

def file_template
  Utils.resource_file('xml_strings_template.txt')
end

#strings_line_with(localization) ⇒ Object



14
15
16
17
18
19
# File 'lib/locraft/generators/xml_strings_generator.rb', line 14

def strings_line_with(localization)
  xml_value = localization.strict_value.gsub('%@', '%s')
  xml_value.gsub!("'", "\\\\'")
  xml_value.gsub!('&', '&')
  %(<string name="#{localization.key}">#{xml_value}</string>\n)
end