handle empty locale file in Transifex pull script

This commit is contained in:
Gerhard Schlager 2017-09-16 23:33:21 +02:00
parent de19c8e70c
commit a1ee61ec25
3 changed files with 3 additions and 3 deletions

View File

@ -5,4 +5,4 @@
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
vi_VN: {}
vi: {}

View File

@ -5,4 +5,4 @@
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
vi_VN: {}
vi: {}

View File

@ -89,7 +89,7 @@ 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)
lines.collect! { |line| line =~ /^[a-z_]+:$/i ? "#{language}:" : line }
lines.collect! { |line| line.gsub!(/^[a-z_]+:( {})?$/i, "#{language}:\\1") || line }
File.open(filename, 'w+') do |f|
f.puts(YML_FILE_COMMENTS, '') unless lines[0][0] == '#'