Class: Lokale::Importer::Diff
- Inherits:
-
Object
- Object
- Lokale::Importer::Diff
- Defined in:
- lib/lokale/agent.rb
Instance Attribute Summary collapse
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#lstrings ⇒ Object
Returns the value of attribute lstrings.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Attribute Details
#lang ⇒ Object
Returns the value of attribute lang.
336 337 338 |
# File 'lib/lokale/agent.rb', line 336 def lang @lang end |
#lstrings ⇒ Object
Returns the value of attribute lstrings.
336 337 338 |
# File 'lib/lokale/agent.rb', line 336 def lstrings @lstrings end |
#name ⇒ Object
Returns the value of attribute name.
336 337 338 |
# File 'lib/lokale/agent.rb', line 336 def name @name end |
Class Method Details
.from_file(xliff_path) ⇒ Object
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/lokale/agent.rb', line 338 def self.from_file(xliff_path) begin xliff = XLIFFer::XLIFF.new(File.open(xliff_path)) rescue Exception => e puts "Failed to parse `#{xliff_path}` file." end diffs = [] xliff.files.each do |f| next if f.target_language == Config.get.main_lang next if f.source_language != Config.get.main_lang diff = Diff.new diff.name = f.original diff.lang = f.target_language diff.lstrings = f.strings .map { |s| LString.from_xliff_string(s, f.target_language) } .delete_if { |ls| ls.target.nil? } next if diff.lstrings.empty? diffs << diff end diffs end |