Commit 0a7767e8 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'bvl-gettext-updated-check-fix' into 'master'

[EE-Port] Updates to the `gettext:updated_check`

See merge request gitlab-org/gitlab-ee!6409
parents fd912b81 c6430785
......@@ -74,9 +74,8 @@ module EE
end
def incorrect_version_message
_("You need git-lfs version %{min_git_lfs_version} (or greater) to
continue. Please visit https://git-lfs.github.com") %
{ min_git_lfs_version: MINIMUM_GIT_LFS_VERSION }
translation = _("You need git-lfs version %{min_git_lfs_version} (or greater) to continue. Please visit https://git-lfs.github.com")
translation % { min_git_lfs_version: MINIMUM_GIT_LFS_VERSION }
end
end
......
......@@ -20,10 +20,9 @@ module EE
def lfs_read_only_message
return super unless ::Gitlab::Geo.secondary_with_primary?
(_('You cannot write to a read-only secondary GitLab Geo instance.
Please use %{link_to_primary_node} instead.') %
{ link_to_primary_node: geo_primary_default_url_to_repo(project) }
).html_safe
translation = _('You cannot write to a read-only secondary GitLab Geo instance. Please use %{link_to_primary_node} instead.')
message = translation % { link_to_primary_node: geo_primary_default_url_to_repo(project) }
message.html_safe
end
end
end
......
......@@ -19,6 +19,23 @@ namespace :gettext do
Rake::Task['gettext:po_to_json'].invoke
end
task :regenerate do
# Remove all translated files, this speeds up finding
FileUtils.rm Dir['locale/**/gitlab.*']
# remove the `pot` file to ensure it's completely regenerated
FileUtils.rm_f 'locale/gitlab.pot'
Rake::Task['gettext:find'].invoke
# leave only the required changes.
`git checkout -- locale/*/gitlab.po`
puts <<~MSG
All done. Please commit the changes to `locale/gitlab.pot`.
MSG
end
desc 'Lint all po files in `locale/'
task lint: :environment do
require 'simple_po_parser'
......@@ -50,13 +67,12 @@ namespace :gettext do
end
task :updated_check do
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.*']
# Make sure we start out with a clean pot.file
`git checkout -- locale/gitlab.pot`
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.
......@@ -64,18 +80,18 @@ namespace :gettext do
Rake::Task['gettext:find'].invoke
end
pot_diff = `git diff -- locale/gitlab.pot`.strip
pot_diff = `git diff -- #{pot_file} | grep -E '^(\\+|-)msgid'`.strip
# reset the locale folder for potential next tasks
`git checkout -- locale`
if pot_diff.present?
raise <<~MSG
Newly translated strings found, please add them to `gitlab.pot` by running:
Newly translated strings found, please add them to `#{pot_file}` by running:
rm locale/**/gitlab.*; bin/rake gettext:find; git checkout -- locale/*/gitlab.po
bin/rake gettext:regenerate
Then commit and push the resulting changes to `locale/gitlab.pot`.
Then commit and push the resulting changes to `#{pot_file}`.
The diff was:
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment