Class: Translatomatic::ResourceFile::XCodeStrings
- Defined in:
- lib/translatomatic/resource_file/xcode_strings.rb
Overview
XCode strings resource file
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.extensions ⇒ Array<String>
File extensions supported by this resource file.
Instance Method Summary collapse
-
#initialize(path, locale = nil) ⇒ Translatomatic::ResourceFile::Base
constructor
Create a new resource file.
-
#save(target = path, options = {}) ⇒ void
Save the resource file.
Methods inherited from Base
#create_variable, #format, #get, #locale_path, #sentences, #set, #supports_variable_interpolation?, #to_s, #valid?, #variable_regex
Constructor Details
#initialize(path, locale = nil) ⇒ Translatomatic::ResourceFile::Base
Create a new resource file. If locale is unspecified, attempts to determine the locale of the file automatically, and if that fails, uses the default locale.
31 32 33 34 35 |
# File 'lib/translatomatic/resource_file/xcode_strings.rb', line 31 def initialize(path, locale = nil) super(path, locale) @valid = true @properties = @path.exist? ? read(@path) : {} end |
Class Method Details
.extensions ⇒ Array<String>
Returns 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 |
Instance Method Details
#save(target = path, options = {}) ⇒ void
This method returns an undefined value.
Save the resource file.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/translatomatic/resource_file/xcode_strings.rb', line 38 def save(target = path, = {}) out = "" out += comment(created_by) unless [:no_created_by] properties.each do |key, value| key = escape(key) value = escape(value) out += %Q{"#{key}" = "#{value}";\n} end target.write(out) end |