From 71421df72ace9314c407b15fc21da2b9ece1b60b Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Fri, 12 Aug 2016 22:12:03 +0200 Subject: [PATCH] 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. --- script/pull_translations.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/script/pull_translations.rb b/script/pull_translations.rb index b8c89015ed4..106e6e0a728 100644 --- a/script/pull_translations.rb +++ b/script/pull_translations.rb @@ -17,11 +17,25 @@ if `which tx`.strip.empty? exit 1 end -languages = Dir.glob(File.expand_path('../../config/locales/client.*.yml', __FILE__)) - .map { |x| x.split('.')[-2] }.select { |x| x != 'en' }.sort +if ARGV.include?('force') + 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...', '' -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| while (line = stdout_err.gets)