Skip to content

Commit

Permalink
Merge pull request #164 from stijnster/master
Browse files Browse the repository at this point in the history
using %{key} in add_missing interpolations
  • Loading branch information
glebm committed Aug 7, 2015
2 parents c5a5310 + b35b838 commit 497c27f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
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

0 comments on commit 497c27f

Please sign in to comment.