Class: Translatomatic::ResourceFile::Subtitle

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

Overview

Subtitle resource file. requires ‘titlekit’ gem

Instance Attribute Summary

Attributes inherited from Base

#locale, #path, #properties

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

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

Class Method Details

.enabled?boolean



12
13
14
15
16
17
18
19
# File 'lib/translatomatic/resource_file/subtitle.rb', line 12

def self.enabled?
  @enabled ||= begin
    require 'titlekit'
    true
  rescue LoadError
    false
  end
end

.extensionsArray<String>



7
8
9
# File 'lib/translatomatic/resource_file/subtitle.rb', line 7

def self.extensions
  %w{srt ass ssa}
end

Instance Method Details

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

This method returns an undefined value.

Save the resource file.



30
31
32
# File 'lib/translatomatic/resource_file/subtitle.rb', line 30

def save(target = path, options = {})
  export(target)
end

#set(key, value) ⇒ String

Set a property



22
23
24
25
26
27
# File 'lib/translatomatic/resource_file/subtitle.rb', line 22

def set(key, value)
  super(key, value)
  if @subtitle_map.include?(key)
    @subtitle_map[key][:lines] = value
  end
end