From f7616d4ffafc13665d5b52b14fbe49afb8b7b9b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 19 Aug 2024 19:21:31 +0200 Subject: [PATCH] Replace inconsistent i18n wit htask --- .github/workflows/i18n-tasks.yml | 44 ++++++++++++++++++++++++++++++++ spec/i18n_spec.rb | 14 ---------- 2 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/i18n-tasks.yml diff --git a/.github/workflows/i18n-tasks.yml b/.github/workflows/i18n-tasks.yml new file mode 100644 index 000000000000..fdc79ac23248 --- /dev/null +++ b/.github/workflows/i18n-tasks.yml @@ -0,0 +1,44 @@ +name: i18n-inconsistency-check + +on: + push: + branches: + - dev + - release/* + paths-ignore: + - 'docs/**' + - 'help/**' + pull_request: + types: [opened, reopened, synchronize] + paths-ignore: + - 'docs/**' + - 'help/**' + - 'packaging/**' + - '.pkgr.yml' + +permissions: + contents: read + +jobs: + i18n-tasks: + permissions: + contents: read + if: github.repository == 'opf/openproject' + name: I18n inconsistency check + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + + - name: Setup i18n-tasks + run: | + gem install i18n-tasks + + - name: Run inconsistent translations check + run: | + i18n-tasks \ + check-consistent-interpolations \ + --config config/i18n-tasks-all-files.yml diff --git a/spec/i18n_spec.rb b/spec/i18n_spec.rb index acb2500075e2..193b3f66c496 100644 --- a/spec/i18n_spec.rb +++ b/spec/i18n_spec.rb @@ -9,7 +9,6 @@ let(:i18n) { I18n::Tasks::BaseTask.new } let(:missing_keys) { i18n.missing_keys } let(:unused_keys) { i18n.unused_keys } - let(:inconsistent_interpolations) { i18n.inconsistent_interpolations } it "does not have missing keys" do pending "Enable when i18n-tasks is enabled across the project, otherwise this spec will report false positives" @@ -30,17 +29,4 @@ "Please run `i18n-tasks normalize' to fix" expect(non_normalized).to be_empty, error_message end - - context "for all i18n files" do - let(:root_dir) { Pathname.new(__FILE__).dirname.join("..") } - let(:config_file) { root_dir.join("config/i18n-tasks-all-files.yml") } - let(:i18n) { I18n::Tasks::BaseTask.new(config_file:) } - - it "does not have inconsistent interpolations" do - config_file_relative_path = config_file.relative_path_from(Dir.pwd) - error_message = "#{inconsistent_interpolations.leaves.count} i18n keys have inconsistent interpolations.\n" \ - "Run 'i18n-tasks check-consistent-interpolations --config #{config_file_relative_path}' to show them" - expect(inconsistent_interpolations).to be_empty, error_message - end - end end