lib/meme-translator/translator.rb
# Change this to the languages you want this to randomly choose from
Change this to the languages you want this to randomly choose from
Change this to the languages you want this to randomly choose from
def translate_file(raw)
    json = JSON.parse(raw)
    lines = json.values.map { |h| h.values.size }.sum
    line = 1
    json.keys.each do |key|
      json[key].keys.each do |k|
        langs = @@languages.keys.sample(@passes) << 'en'
        if json[key][k].start_with?("{$")
          puts "Skipping phrase '#{json[key][k]}', as it isn't localized."
        else
          puts "Starting with phrase: '#{json[key][k]}'"
          (@passes + 1).times do |i|
            from = i == 0 ? nil : langs[i - 1]
            json[key][k], code = translate_phrase(json[key][k], langs[i], from)
            if code
              return json
            end
          end
          if json[key][k].size <= 15 || json[key][k].end_with?(".")
            json[key][k] = json[key][k][0...-1]
          end
          puts "Final output after #{@passes + 1} passes: '#{json[key][k]}'"
          puts "Completed line #{line}/#{lines}."
          puts ""
          line += 1
        end
      end
    end
    return json
  end
def translate_file ( raw ) json = JSON . parse ( raw ) lines = json . values . map { | h | h . values . size } . sum line = 1 json . keys . each do | key | json [ key ] . keys . each do | k | langs = @@languages . keys . sample ( @passes ) << 'en' if json [ key ] [ k ] . start_with? ( "{$" ) puts "Skipping phrase '#{json[key][k]}', as it isn't localized." else puts "Starting with phrase: '#{json[key][k]}'" ( @passes + 1 ) . times do | i | from = i == 0 ? nil : langs [ i - 1 ] json [ key ] [ k ] , code = translate_phrase ( json [ key ] [ k ] , langs [ i ] , from ) if code return json end end if json [ key ] [ k ] . size <= 15 || json [ key ] [ k ] . end_with? ( "." ) json [ key ] [ k ] = json [ key ] [ k ] [ 0 ... - 1 ] end puts "Final output after #{@passes + 1} passes: '#{json[key][k]}'" puts "Completed line #{line}/#{lines}." puts "" line += 1 end end end return json end
Change this to the languages you want this to randomly choose from
Change this to the languages you want this to randomly choose from
raw
<not_specific>