From 9a4f7a1282a82322d7f97d1f6f1e91b1c2f9c3a3 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Tue, 23 Oct 2018 20:06:29 +0100 Subject: [PATCH] Fix interpolations with repeated vars --- CHANGES.md | 4 ++++ README.md | 2 +- lib/i18n/tasks/interpolations.rb | 3 +-- lib/i18n/tasks/version.rb | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2fe17c61..e84045f0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +## v0.9.27 + +* Fixes `check-consistent-interpolations` when the same interpolation is used more than once. + ## v0.9.26 * `eq-base` command now returns a non-zero exit code if there are any results. diff --git a/README.md b/README.md index 7b476858..c45e1474 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ i18n-tasks can be used with any project using the ruby [i18n gem][i18n-gem] (def Add i18n-tasks to the Gemfile: ```ruby -gem 'i18n-tasks', '~> 0.9.26' +gem 'i18n-tasks', '~> 0.9.27' ``` Copy the default [configuration file](#configuration): diff --git a/lib/i18n/tasks/interpolations.rb b/lib/i18n/tasks/interpolations.rb index 712bd9a5..83bf132f 100644 --- a/lib/i18n/tasks/interpolations.rb +++ b/lib/i18n/tasks/interpolations.rb @@ -15,8 +15,7 @@ def inconsistent_interpolations(locales: nil, base_locale: nil) # rubocop:disabl (locales - [base_locale]).each do |current_locale| node = data[current_locale].first.children[key] next unless node&.value&.is_a?(String) - vars = node.value.scan(VARIABLE_REGEX) - unless vars.size == base_vars.size && vars.all? { |v| base_vars.include?(v) } + if base_vars != Set.new(node.value.scan(VARIABLE_REGEX)) result.merge!(node.walk_to_root.reduce(nil) { |c, p| [p.derive(children: c)] }) end end diff --git a/lib/i18n/tasks/version.rb b/lib/i18n/tasks/version.rb index 481fe4a7..1b252f13 100644 --- a/lib/i18n/tasks/version.rb +++ b/lib/i18n/tasks/version.rb @@ -2,6 +2,6 @@ module I18n module Tasks - VERSION = '0.9.26' + VERSION = '0.9.27' end end