Do not create empty files when pulling from Transifex

This commit is contained in:
Gerhard Schlager 2018-04-06 14:47:25 +02:00
parent 09c4491f73
commit 8412a96acb
1 changed files with 7 additions and 5 deletions

View File

@ -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)