class Terrestrial::Cli::Pull::ProcessesTranslations
Public Class Methods
new(translations, local_strings, platform)
click to toggle source
# File lib/terrestrial/cli/pull/processes_translations.rb, line 9 def initialize(translations, local_strings, platform) @translations = translations @local_strings = local_strings @platform = platform end
run(translations, local_strings, platform)
click to toggle source
# File lib/terrestrial/cli/pull/processes_translations.rb, line 5 def self.run(translations, local_strings, platform) new(translations, local_strings, platform).run end
Public Instance Methods
find_translation_for_id(id)
click to toggle source
# File lib/terrestrial/cli/pull/processes_translations.rb, line 49 def find_translation_for_id(id) translations.detect {|t| t["id"] == id } end
process_android()
click to toggle source
# File lib/terrestrial/cli/pull/processes_translations.rb, line 32 def process_android translations .reject {|entry| entry["translation"].nil? || entry["translation"].empty? } .map {|entry| TranslatedString.new(entry["translation"], entry["id"], false) } end
process_ios()
click to toggle source
# File lib/terrestrial/cli/pull/processes_translations.rb, line 38 def process_ios local_strings.map do |local_string| match = find_translation_for_id(local_string["identifier"]) if match TranslatedString.new(match["translation"], match["id"], false) else TranslatedString.new(local_string["string"], local_string["identifier"], true) end end end
process_unity()
click to toggle source
# File lib/terrestrial/cli/pull/processes_translations.rb, line 28 def process_unity process_android end
run()
click to toggle source
# File lib/terrestrial/cli/pull/processes_translations.rb, line 15 def run case platform when "ios" process_ios when "android" process_android when "unity" process_unity else raise "Unknown platform" end end
Private Instance Methods
local_strings()
click to toggle source
# File lib/terrestrial/cli/pull/processes_translations.rb, line 59 def local_strings @local_strings end
platform()
click to toggle source
# File lib/terrestrial/cli/pull/processes_translations.rb, line 63 def platform @platform end
translations()
click to toggle source
# File lib/terrestrial/cli/pull/processes_translations.rb, line 55 def translations @translations end