Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using %{key} in add_missing interpolations #164

Merged
merged 3 commits into from
Aug 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified bin/i18n-tasks.cmd
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions lib/i18n/tasks/data/tree/traversal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,12 @@ def set_each_value!(val_pattern, key_pattern = nil, &value_proc)
value_proc ||= proc { |node|
node_value = node.value
human_key = ActiveSupport::Inflector.humanize(node.key.to_s)
full_key = node.full_key
StringInterpolation.interpolate_soft(
val_pattern,
value: node_value,
human_key: human_key,
key: full_key,
value_or_human_key: node_value.presence || human_key
)
}
Expand Down
11 changes: 11 additions & 0 deletions spec/i18n_tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@
expect(YAML.load_file('config/locales/en.yml')['en']['present_in_es_but_not_en']['a']).to eq 'TRME ES_TEXT'
}
end

it '--value with %{key}' do
in_test_app_dir {
expect(YAML.load_file('config/locales/es.yml')['es']['missing_in_es']).to be_nil
}
run_cmd 'add-missing', '-v', 'TRME %{key}'
in_test_app_dir {
expect(YAML.load_file('config/locales/es.yml')['es']['missing_in_es']['a']).to eq 'TRME es.missing_in_es.a'
expect(YAML.load_file('config/locales/en.yml')['en']['present_in_es_but_not_en']['a']).to eq 'TRME en.present_in_es_but_not_en.a'
}
end
end

describe 'config' do
Expand Down