Skip to content

Instantly share code, notes, and snippets.

@edouard
Created June 6, 2012 09:55
Show Gist options
  • Save edouard/2881038 to your computer and use it in GitHub Desktop.
Save edouard/2881038 to your computer and use it in GitHub Desktop.
This ruby script will pull all your strings from WebTranslateIt.com and format them under the Apple .strings format
# This ruby script will pull all your strings from WebTranslateIt.com
# and format them under the Apple .strings format
# beforehand: `gem install web_translate_it`
# make sure you’re using the version 2.0.2 which implements pagination on `String.find_all`
require 'web_translate_it'
api_key = 'sekret'
WebTranslateIt::Connection.new(api_key) do
file = File.new("Localizable.strings", "w")
WebTranslateIt::String.find_all.each do |segment|
puts "Adding #{segment.key}"
translation = segment.translation_for('en')
if translation
file.puts "\"#{segment.key}\" = \"#{translation.text}\""
else
file.puts "\"#{segment.key}\" = \"\""
end
end
file.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment