diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-05-07 19:39:46 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-06-15 15:58:47 +0300 |
commit | 9b5339371b500829b87602cfe7ba773e1027109f (patch) | |
tree | c21fa625bdedbab6727add0cf84b19cb919215d5 /lib | |
parent | a9ebcfa5f55fe8444d9c0058904a9f1dbee7e32e (diff) |
Validate if changed translations are checked in
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/gettext.rake | 26 | ||||
-rw-r--r-- | lib/tasks/lint.rake | 1 |
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index 247d7be7d78..efe2997d78e 100644 --- a/lib/tasks/gettext.rake +++ b/lib/tasks/gettext.rake @@ -50,6 +50,32 @@ namespace :gettext do end end + task :updated_check do + # Removeing all pre-translated files speeds up `gettext:find` as the + # files don't need to be merged. + `rm locale/*/gitlab.po` + + # `gettext:find` writes touches to temp files to `stderr` which would cause + # `static-analysis` to report failures. We can ignore these + silence_stream(STDERR) { Rake::Task['gettext:find'].invoke } + + changed_files = `git diff --name-only`.lines.map(&:strip) + + # reset the locale folder for potential next tasks + `git checkout locale` + + if changed_files.include?('locale/gitlab.pot') + raise <<~MSG + Newly translated strings found, please add them to `gitlab.pot` by running: + + bundle exec rake gettext:find; git checkout locale/*/gitlab.po; + + Then check in the resulting `locale/gitlab.pot` + + MSG + end + end + def report_errors_for_file(file, errors_for_file) puts "Errors in `#{file}`:" diff --git a/lib/tasks/lint.rake b/lib/tasks/lint.rake index 8b86a5c72a5..b5a9cddaacb 100644 --- a/lib/tasks/lint.rake +++ b/lib/tasks/lint.rake @@ -27,6 +27,7 @@ unless Rails.env.production? scss_lint flay gettext:lint + gettext:updated_check lint:static_verification ].each do |task| pid = Process.fork do |