Skip to content

A platform for community discussion. Free, open, simple.

Do not create empty files when pulling from Transifex

Gerhard Schlager8412a96acb9d
diff --git a/script/pull_translations.rb b/script/pull_translations.rb
index a82abce68e0..8b5faedb413 100644
--- a/script/pull_translations.rb
+++ b/script/pull_translations.rb
@@ -48,11 +48,18 @@ def yml_path(dir, prefix, language)
File.expand_path(path, __FILE__)
end
+def yml_path_if_exists(dir, prefix, language)
+ path = yml_path(dir, prefix, language)
+ File.exists?(path) ? path : nil
+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|
+ next unless yml_path_if_exists(dir, prefix, 'en')
+
languages.each do |language|
filename = yml_path(dir, prefix, language)
FileUtils.touch(filename) unless File.exists?(filename)
@@ -86,11 +93,6 @@ YML_FILE_COMMENTS = <<END
# https://www.transifex.com/projects/p/discourse-org/
END
-def yml_path_if_exists(dir, prefix, language)
- path = yml_path(dir, prefix, language)
- File.exists?(path) ? path : nil
-end
-
# Add comments to the top of files and replace the language (first key in YAML file)
def update_file_header(filename, language)
lines = File.readlines(filename)