Created
June 6, 2012 09:55
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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