Last active
June 21, 2016 01:56
-
-
Save jfsso/c82102dded15a1cefc53994a96dfed6d to your computer and use it in GitHub Desktop.
Script that downloads translated Android strings in languages marked as "ready" from OneSky
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
require 'onesky' | |
require 'fileutils' | |
# Settings | |
project_id = XXXXX | |
# Create client | |
client = Onesky::Client.new('<api_key>', '<api_secret>') | |
# show project details | |
project = client.project(project_id) | |
resp = JSON.parse(project.show) | |
p resp['data'] | |
# get language list | |
resp = JSON.parse(project.list_language) | |
#p resp['data'] | |
# download translations that are ready | |
resp['data'].each do |x| | |
if (x['is_ready_to_publish']) | |
locale = x['custom_locale'] || x['locale'] | |
print "Downloading ", x['english_name'], " (", x['code'], ") with translation progress of ", x['translation_progress'], " to values-", locale, "... " | |
resp = project.export_translation(source_file_name: 'strings.xml', locale: x['code']) | |
path = 'app/src/main/res/values-' + locale | |
FileUtils.mkdir_p(path) unless File.exists?(path) | |
File.open(path + '/strings.xml', 'w') { |file| file.write(resp)} | |
puts "Done!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment