Class: Locca::Genstrings

Inherits:
Object
  • Object
show all
Defined in:
lib/locca/genstrings.rb

Instance Method Summary collapse

Instance Method Details

#generate(source_files) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/locca/genstrings.rb', line 30

def generate(source_files)
    Dir.mktmpdir do |tmp_dir|
        file_list = "'" + source_files.join("' '") + "'"
        command = "genstrings -o '#{tmp_dir}' #{file_list}"
        stdout, stderr, status = Open3.capture3(command)

        stderr = stderr.strip
        if stderr.length > 0
            STDERR.puts()
        end

        if status.success?
            Dir.glob(File.join(tmp_dir, '*.strings')) do |filename|
                yield(filename)
            end
        else
            raise "genstrings failed"
        end
    end
end