Always use --force when pulling translations from Transifex

Also, this makes it possible to pull only selected languages which is
handy during development and for adding a new language.
This commit is contained in:
Gerhard Schlager 2016-08-12 22:12:03 +02:00
parent aef954784a
commit 71421df72a
No known key found for this signature in database
GPG key ID: 7DACA3C95B36014B

View file

@ -17,11 +17,25 @@ if `which tx`.strip.empty?
exit 1 exit 1
end end
languages = Dir.glob(File.expand_path('../../config/locales/client.*.yml', __FILE__)) if ARGV.include?('force')
.map { |x| x.split('.')[-2] }.select { |x| x != 'en' }.sort STDERR.puts 'Usage: ruby pull_translations.rb [languages]'
STDERR.puts 'Example: ruby pull_translations.rb de it', ''
exit 1
end
def get_languages
if ARGV.empty?
Dir.glob(File.expand_path('../../config/locales/client.*.yml', __FILE__))
.map { |x| x.split('.')[-2] }
else
ARGV
end
end
languages = get_languages.select { |x| x != 'en' }.sort
puts 'Pulling new translations...', '' puts 'Pulling new translations...', ''
command = "tx pull --mode=developer --language=#{languages.join(',')} #{ARGV.include?('force') ? '-f' : ''}" command = "tx pull --mode=developer --language=#{languages.join(',')} --force"
Open3.popen2e(command) do |stdin, stdout_err, wait_thr| Open3.popen2e(command) do |stdin, stdout_err, wait_thr|
while (line = stdout_err.gets) while (line = stdout_err.gets)