Class: Translatomatic::ResourceFile::XCodeStrings

Inherits:
Base
  • Object
show all
Defined in:
lib/translatomatic/resource_file/xcode_strings.rb

Overview

XCode strings resource file

Instance Attribute Summary

Attributes inherited from Base

#locale, #path, #properties

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#create_variable, enabled?, #format, #get, #initialize, #locale_path, #sentences, #set, supports_variable_interpolation?, #to_s, #type, #variable_regex

Constructor Details

This class inherits a constructor from Translatomatic::ResourceFile::Base

Class Method Details

.extensionsArray<String>

Returns File extensions supported by this resource file.

Returns:

  • (Array<String>)

    File extensions supported by this resource file



26
27
28
# File 'lib/translatomatic/resource_file/xcode_strings.rb', line 26

def self.extensions
  %w{strings}
end

.is_key_value?boolean

Returns True if the file format consists of keys and values.

Returns:

  • (boolean)

    True if the file format consists of keys and values



31
32
33
# File 'lib/translatomatic/resource_file/xcode_strings.rb', line 31

def self.is_key_value?
  true
end

Instance Method Details

#save(target = path, options = {}) ⇒ void

This method returns an undefined value.

Save the resource file.

Parameters:

  • target (Pathname) (defaults to: path)

    The destination path

  • options (Hash<Symbol, Object>) (defaults to: {})

    Output format options



36
37
38
39
40
41
42
43
44
45
# File 'lib/translatomatic/resource_file/xcode_strings.rb', line 36

def save(target = path, options = {})
  out = ""
  out += comment(created_by) unless options[:no_created_by]
  properties.each do |key, value|
    key = escape(key)
    value = escape(value)
    out += %Q{"#{key}" = "#{value}";\n}
  end
  target.write(out)
end