Skip to content

Commit

Permalink
s/inconsistent_interpolation/inconsistent_interpolations
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Oct 23, 2018
1 parent 56a5858 commit 1b62d84
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion config/locales/en.yml
Expand Up @@ -103,7 +103,7 @@ en:
Google Translate returned no results. Make sure billing information is set at https://code.google.com/apis/console.
health:
no_keys_detected: No keys detected. Check data.read in config/i18n-tasks.yml.
inconsistent_interpolation:
inconsistent_interpolations:
none: No inconsistent interpolations found.
missing:
details_title: Value in other locales or source
Expand Down
8 changes: 4 additions & 4 deletions config/locales/ru.yml
Expand Up @@ -9,7 +9,7 @@ ru:
desc:
all_locales: Не ожидать, что маски ключа начинаются с локали. Применять маски ко всем локалям.
confirm: Подтвердить автоматом
data_format: 'Формат данных: %{valid_text}. %{default_text}.'
data_format: 'Формат данных: %{valid_text}.'
keep_order: Keep the order of the keys
key_pattern: Маска ключа (например, common.*)
key_pattern_to_rename: Полный ключ (шаблон) для переименования. Необходимый параметр.
Expand All @@ -21,7 +21,7 @@ ru:
missing_types: 'Типы недостающих переводов: %{valid}. По умолчанию: все'
new_key_name: Новое имя, интерполирует оригинальное название как %{key}. Необходимый параметр.
nostdin: Не читать дерево из стандартного ввода
out_format: 'Формат вывода: %{valid_text}. %{default_text}.'
out_format: 'Формат вывода: %{valid_text}.'
pattern_router: 'Использовать pattern_router: ключи распределятся по файлам согласно data.write'
strict: Не угадывать динамические использования ключей, например `t("category.#{category.key}")`
translation_backend: Движок перевода (google или deepl)
Expand Down Expand Up @@ -101,14 +101,14 @@ ru:
в https://code.google.com/apis/console.
health:
no_keys_detected: Ключи не обнаружены. Проверьте data.read в config/i18n-tasks.yml.
inconsistent_interpolation:
inconsistent_interpolations:
none: Не найдено несогласованных интерполяций.
missing:
details_title: На других языках или в коде
none: Всё переведено.
remove_unused:
confirm:
one: Один перевод будут удалён из %{locales}.
one: "%{count} перевод будут удалён из %{locales}."
other: Переводы (%{count}) будут удалены из %{locales}.
noop: Нет неиспользуемых ключей
removed: Удалены ключи (%{count})
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/tasks/command/commands/health.rb
Expand Up @@ -19,8 +19,8 @@ def health(opt = {})
[
missing(opt),
unused(opt),
check_consistent_interpolations(opt),
check_normalized(opt),
check_consistent_interpolations(opt)
].detect { |result| result == :exit_1 }
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/i18n/tasks/command/commands/interpolations.rb
Expand Up @@ -12,8 +12,8 @@ module Interpolations
args: %i[locales out_format]

def check_consistent_interpolations(opt = {})
forest = i18n.inconsistent_interpolation(opt.slice(:locales, :base_locale))
print_forest forest, opt, :inconsistent_interpolation
forest = i18n.inconsistent_interpolations(opt.slice(:locales, :base_locale))
print_forest forest, opt, :inconsistent_interpolations
:exit_1 unless forest.empty?
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/i18n/tasks/interpolations.rb
Expand Up @@ -4,13 +4,13 @@ module I18n::Tasks
module Interpolations
VARIABLE_REGEX = /%{[^}]+}/

def inconsistent_interpolation(locales: nil, base_locale: nil) # rubocop:disable Metrics/AbcSize
def inconsistent_interpolations(locales: nil, base_locale: nil) # rubocop:disable Metrics/AbcSize
locales ||= self.locales
base_locale ||= self.base_locale
result = empty_forest

data[base_locale].key_values.each do |key, value|
next if !value.is_a?(String) || ignore_key?(key, :inconsistent)
next if !value.is_a?(String) || ignore_key?(key, :inconsistent_interpolations)
base_vars = Set.new(value.scan(VARIABLE_REGEX))
(locales - [base_locale]).each do |current_locale|
node = data[current_locale].first.children[key]
Expand All @@ -22,7 +22,7 @@ def inconsistent_interpolation(locales: nil, base_locale: nil) # rubocop:disable
end
end

result.each { |root| root.data[:type] = :inconsistent_interpolation }
result.each { |root| root.data[:type] = :inconsistent_interpolations }
result
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/tasks/reports/base.rb
Expand Up @@ -21,7 +21,7 @@ def missing_title(forest)
"Missing translations (#{forest.leaves.count || '∅'})"
end

def inconsistent_interpolation_title(forest)
def inconsistent_interpolations_title(forest)
"Inconsistent interpolations (#{forest.leaves.count || '∅'})"
end

Expand Down
6 changes: 3 additions & 3 deletions lib/i18n/tasks/reports/terminal.rb
Expand Up @@ -25,12 +25,12 @@ def missing_keys(forest = task.missing_keys)
end
end

def inconsistent_interpolation(forest = task.inconsistent_interpolation)
def inconsistent_interpolations(forest = task.inconsistent_interpolations)
if forest.present?
print_title inconsistent_interpolation_title(forest)
print_title inconsistent_interpolations_title(forest)
show_tree(forest)
else
print_success I18n.t('i18n_tasks.inconsistent_interpolation.none')
print_success I18n.t('i18n_tasks.inconsistent_interpolations.none')
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/interpolations_spec.rb
Expand Up @@ -20,7 +20,7 @@
end

it '#inconsistent_interpolation' do
wrong = task.inconsistent_interpolation
wrong = task.inconsistent_interpolations
leaves = wrong.leaves.to_a

expect(leaves.size).to eq 3
Expand Down
2 changes: 1 addition & 1 deletion templates/config/i18n-tasks.yml
Expand Up @@ -112,7 +112,7 @@ search:
# - common.brand

## Exclude these keys from the `i18n-tasks check-consistent-interpolations` report:
# ignore_inconsistent:
# ignore_inconsistent_interpolations:
# - 'activerecord.attributes.*'

## Ignore these keys completely:
Expand Down

0 comments on commit 1b62d84

Please sign in to comment.