diff options
Diffstat (limited to 'lib/tasks/gettext.rake')
-rw-r--r-- | lib/tasks/gettext.rake | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index 2235a6ba194..81754bb9eeb 100644 --- a/lib/tasks/gettext.rake +++ b/lib/tasks/gettext.rake @@ -4,8 +4,8 @@ namespace :gettext do # Customize list of translatable files # See: https://github.com/grosser/gettext_i18n_rails#customizing-list-of-translatable-files def files_to_translate - folders = %W(ee app lib config #{locale_path}).join(',') - exts = %w(rb erb haml slim rhtml js jsx vue handlebars hbs mustache).join(',') + folders = %W[ee app lib config #{locale_path}].join(",") + exts = %w[rb erb haml slim rhtml js jsx vue handlebars hbs mustache].join(",") Dir.glob( "{#{folders}}/**/*.{#{exts}}" @@ -14,55 +14,55 @@ namespace :gettext do task :compile do # See: https://gitlab.com/gitlab-org/gitlab-ce/issues/33014#note_31218998 - FileUtils.touch(File.join(Rails.root, 'locale/gitlab.pot')) + FileUtils.touch(File.join(Rails.root, "locale/gitlab.pot")) - Rake::Task['gettext:po_to_json'].invoke + Rake::Task["gettext:po_to_json"].invoke end task :regenerate do - pot_file = 'locale/gitlab.pot' + pot_file = "locale/gitlab.pot" # Remove all translated files, this speeds up finding - FileUtils.rm Dir['locale/**/gitlab.*'] + FileUtils.rm Dir["locale/**/gitlab.*"] # remove the `pot` file to ensure it's completely regenerated FileUtils.rm_f pot_file - Rake::Task['gettext:find'].invoke + Rake::Task["gettext:find"].invoke # leave only the required changes. `git checkout -- locale/*/gitlab.po` # Remove timestamps from the pot file pot_content = File.read pot_file - pot_content.gsub!(/^"POT?\-(?:Creation|Revision)\-Date\:.*\n/, '') + pot_content.gsub!(/^"POT?\-(?:Creation|Revision)\-Date\:.*\n/, "") File.write pot_file, pot_content puts <<~MSG - All done. Please commit the changes to `locale/gitlab.pot`. + All done. Please commit the changes to `locale/gitlab.pot`. MSG end - desc 'Lint all po files in `locale/' + desc "Lint all po files in `locale/" task lint: :environment do - require 'simple_po_parser' - require 'gitlab/utils' + require "simple_po_parser" + require "gitlab/utils" FastGettext.silence_errors - files = Dir.glob(Rails.root.join('locale/*/gitlab.po')) + files = Dir.glob(Rails.root.join("locale/*/gitlab.po")) - linters = files.map do |file| + linters = files.map { |file| locale = File.basename(File.dirname(file)) Gitlab::I18n::PoLinter.new(file, locale) - end + } - pot_file = Rails.root.join('locale/gitlab.pot') + pot_file = Rails.root.join("locale/gitlab.pot") linters.unshift(Gitlab::I18n::PoLinter.new(pot_file)) failed_linters = linters.select { |linter| linter.errors.any? } if failed_linters.empty? - puts 'All PO files are valid.' + puts "All PO files are valid." else failed_linters.each do |linter| report_errors_for_file(linter.po_path, linter.errors) @@ -73,17 +73,17 @@ namespace :gettext do end task :updated_check do - pot_file = 'locale/gitlab.pot' + pot_file = "locale/gitlab.pot" # Removing all pre-translated files speeds up `gettext:find` as the # files don't need to be merged. # Having `LC_MESSAGES/gitlab.mo files present also confuses the output. - FileUtils.rm Dir['locale/**/gitlab.*'] + FileUtils.rm Dir["locale/**/gitlab.*"] FileUtils.rm_f pot_file # `gettext:find` writes touches to temp files to `stderr` which would cause # `static-analysis` to report failures. We can ignore these. silence_stderr do - Rake::Task['gettext:find'].invoke + Rake::Task["gettext:find"].invoke end pot_diff = `git diff -- #{pot_file} | grep -E '^(\\+|-)msgid'`.strip @@ -112,8 +112,8 @@ namespace :gettext do errors_for_file.each do |message_id, errors| puts " #{message_id}" errors.each do |error| - spaces = ' ' * 4 - error = error.lines.join("#{spaces}") + spaces = " " * 4 + error = error.lines.join(spaces.to_s) puts "#{spaces}#{error}" end end |