Method: Babelish::XcodeMacros#process

Defined in:
lib/babelish/xcode_macros.rb

#process(table, keys, comments = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/babelish/xcode_macros.rb', line 16

def process(table, keys, comments = {})
  keys.each do |key|
    clean_key = key.gsub(' ', '')
    clean_key.gsub!(/[[:punct:]]/, '_')       
    clean_key.gsub!('__', '_')
    clean_key = clean_key[1..clean_key.size-1] if clean_key[0] == '_'
    clean_key = clean_key[0..clean_key.size-2] if clean_key.size > 1 and clean_key[clean_key.size-1] == '_'
    macro_name = "LS_#{clean_key.upcase}" 
    macro_name += "_#{table.upcase}" if table != "Localizable" 
    comment = comments[key]
    @content << String.new("#define \#{macro_name} NSLocalizedStringFromTable(@\"\#{key}\",@\"\#{table}\",@\"\#{comment.to_s}\")\n    EOS\n  end\n  @content\nend\n")