Class: Babelish::CSV2Strings

Inherits:
Csv2Base show all
Defined in:
lib/babelish/csv2strings.rb

Instance Attribute Summary collapse

Attributes inherited from Csv2Base

#comments_column, #csv_filename, #csv_separator, #default_lang, #excluded_states, #ignore_lang_path, #keys_column, #langs, #output_dir, #state_column

Instance Method Summary collapse

Methods inherited from Csv2Base

#comments, #convert, #create_file_from_path, #default_filepath, #hash_to_output, #initialize, #keys, #process_value, #table, #write_content

Constructor Details

This class inherits a constructor from Babelish::Csv2Base

Instance Attribute Details

#languagesObject

Returns the value of attribute languages.



3
4
5
# File 'lib/babelish/csv2strings.rb', line 3

def languages
  @languages
end

Instance Method Details

#extensionObject



23
24
25
# File 'lib/babelish/csv2strings.rb', line 23

def extension
  "strings"
end

#get_row_format(row_key, row_value, comment = nil, indentation = 0) ⇒ Object



18
19
20
21
# File 'lib/babelish/csv2strings.rb', line 18

def get_row_format(row_key, row_value, comment = nil, indentation = 0)
  entry = comment.to_s.empty? ? "" : "\n/* #{comment} */\n" 
  entry + "\"#{row_key}\"" + " " * indentation + " = \"#{row_value}\";\n"
end

#language_filepaths(language) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/babelish/csv2strings.rb', line 5

def language_filepaths(language)
  require 'pathname'
  filepaths = []
  if language.regions.empty?
    filepaths << Pathname.new(@output_dir) + "#{language.code}.lproj/#{output_basename}.#{extension}"
  else
    language.regions.each do |region|
      filepaths << Pathname.new(@output_dir) + "#{language.code}-#{region}.lproj/#{output_basename}.#{extension}"
    end
  end
  filepaths
end

#output_basenameObject



27
28
29
# File 'lib/babelish/csv2strings.rb', line 27

def output_basename
  @output_basename || 'Localizable'
end