Skip to content

Instantly share code, notes, and snippets.

@paulmolluzzo
Created July 8, 2014 01:36
Show Gist options
  • Save paulmolluzzo/49243f515eccf65ab0d7 to your computer and use it in GitHub Desktop.
Save paulmolluzzo/49243f515eccf65ab0d7 to your computer and use it in GitHub Desktop.
Easy Translate
#!/usr/bin/ruby
require 'easy_translate'
EasyTranslate.api_key = '' #Get from google
target_path = '' # path to translate
Dir.glob(target_path) do |item|
next if item == '.' or item == '..' or item == '.svn'
contents = ""
update = ""
File.open(item, "r") do |file|
contents += file.read
update += EasyTranslate.translate(contents, :from => :russian, :to => :en)
end
File.open(item, "w"){ }
File.open(item, "w") do |file|
file.write(update)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment