Skip to content

Instantly share code, notes, and snippets.

@edouard
Created July 27, 2012 07:51
Show Gist options
  • Save edouard/3186714 to your computer and use it in GitHub Desktop.
Save edouard/3186714 to your computer and use it in GitHub Desktop.
Output a WebTranslateIt project’s translations to a .csv file
# before using: gem install web_translate_it
require 'web_translate_it'
file = File.new("my_file.csv", "w")
locales = %w{en fr de it ru sv}
file.puts "key," + locales.join(",")
WebTranslateIt::Connection.new('api_key') do
puts "Fetching all strings in project..."
WebTranslateIt::String.find_all.each do |string|
puts string.key
to_put = [string.key]
locales.each do |locale|
translation = string.translation_for(locale)
to_put << (translation.nil? ? "" : translation.text.to_s)
end
file.puts to_put.join(",")
end
end
file.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment