Class: Translatomatic::ResourceFile::Plist

Inherits:
XML
  • Object
show all
Defined in:
lib/translatomatic/resource_file/plist.rb

Instance Attribute Summary

Attributes inherited from Base

#locale, #path, #properties

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from XML

#initialize, #save, #set

Methods inherited from Base

#format, #get, #initialize, #save, #sentences, #set, #to_s, #valid?

Methods included from Util

#locale, #log, #string

Constructor Details

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

Class Method Details

.extensionsArray<String>

Returns File extensions supported by this resource file.

Returns:

  • (Array<String>)

    File extensions supported by this resource file



5
6
7
# File 'lib/translatomatic/resource_file/plist.rb', line 5

def self.extensions
  %w{plist}
end

Instance Method Details

#locale_path(locale) ⇒ Pathname

TODO:

refactor this and xcode_strings.rb to use the same code

Note:

localization files in XCode use the following file name convention: Project/locale.lproj/filename

Create a path for the current resource file with a given locale

Parameters:

  • locale (String)

    for the path

Returns:

  • (Pathname)

    The path of this resource file modified for the given locale



13
14
15
16
17
18
19
20
21
# File 'lib/translatomatic/resource_file/plist.rb', line 13

def locale_path(locale)
  if path.to_s.match(/\/([-\w]+).lproj\/.+.plist$/)
    # xcode style
    filename = path.basename
    path.parent.parent + (locale.to_s + ".lproj") + filename
  else
    super(locale)
  end
end