diff --git a/script/pull_translations.rb b/script/pull_translations.rb index 2acb4d2dab1..a739b0da47f 100644 --- a/script/pull_translations.rb +++ b/script/pull_translations.rb @@ -8,8 +8,14 @@ require 'open3' require 'psych' require 'set' +require 'fileutils' require_relative '../lib/i18n/locale_file_walker' +YML_DIRS = ['config/locales', + 'plugins/poll/config/locales', + 'plugins/discourse-narrative-bot/config/locales'] +YML_FILE_PREFIXES = ['server', 'client'] + if `which tx`.strip.empty? puts '', 'The Transifex client needs to be installed to use this script.' puts 'Instructions are here: http://docs.transifex.com/client/setup/' @@ -34,8 +40,23 @@ def get_languages end end +def yml_path(dir, prefix, language) + path = "../../#{dir}/#{prefix}.#{language}.yml" + File.expand_path(path, __FILE__) +end + languages = get_languages.select { |x| x != 'en' }.sort +# ensure that all locale files exists. tx doesn't create missing locale files during pull +YML_DIRS.each do |dir| + YML_FILE_PREFIXES.each do |prefix| + languages.each do |language| + filename = yml_path(dir, prefix, language) + FileUtils.touch(filename) unless File.exists?(filename) + end + end +end + puts 'Pulling new translations...', '' command = "tx pull --mode=developer --language=#{languages.join(',')} --force" @@ -60,14 +81,8 @@ YML_FILE_COMMENTS = <