From a1ee61ec25d8de128faf46d765d1aeda9d880654 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Sat, 16 Sep 2017 23:33:21 +0200 Subject: [PATCH] handle empty locale file in Transifex pull script --- plugins/discourse-narrative-bot/config/locales/client.vi.yml | 2 +- plugins/discourse-narrative-bot/config/locales/server.vi.yml | 2 +- script/pull_translations.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/discourse-narrative-bot/config/locales/client.vi.yml b/plugins/discourse-narrative-bot/config/locales/client.vi.yml index 97b13f94972..fa809fe162c 100644 --- a/plugins/discourse-narrative-bot/config/locales/client.vi.yml +++ b/plugins/discourse-narrative-bot/config/locales/client.vi.yml @@ -5,4 +5,4 @@ # To work with us on translations, join this project: # https://www.transifex.com/projects/p/discourse-org/ -vi_VN: {} +vi: {} diff --git a/plugins/discourse-narrative-bot/config/locales/server.vi.yml b/plugins/discourse-narrative-bot/config/locales/server.vi.yml index 97b13f94972..fa809fe162c 100644 --- a/plugins/discourse-narrative-bot/config/locales/server.vi.yml +++ b/plugins/discourse-narrative-bot/config/locales/server.vi.yml @@ -5,4 +5,4 @@ # To work with us on translations, join this project: # https://www.transifex.com/projects/p/discourse-org/ -vi_VN: {} +vi: {} diff --git a/script/pull_translations.rb b/script/pull_translations.rb index a739b0da47f..e5e6dce8972 100644 --- a/script/pull_translations.rb +++ b/script/pull_translations.rb @@ -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] == '#'