Skip to content

Commit

Permalink
Replace inconsistent i18n wit htask
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Aug 19, 2024
1 parent a79c00a commit e56efdf
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 14 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/i18n-tasks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: i18n-incosistency-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
14 changes: 0 additions & 14 deletions spec/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

0 comments on commit e56efdf

Please sign in to comment.