Skip to content

Commit

Permalink
Dashes are valid in keys, see #64
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Jun 5, 2014
1 parent df84455 commit ac94281
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/i18n/tasks/scanners/base_scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def strip_literal(literal)
key
end

VALID_KEY_RE = /^[\w.\#{}]+$/
VALID_KEY_RE = /^[-\w.\#{}]+$/

def valid_key?(key)
key =~ VALID_KEY_RE && !(@key_filter && @key_filter_pattern !~ key)
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/app/views/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ p #{t('ca.a')} #{t 'ca.b'} #{t "ca.c"}
p #{t 'ca.d'} #{t 'ca.f', i: 'world'} #{t 'ca.e', i: 'world'}
p #{t 'missing_in_es.a'} #{t 'same_in_es.a'} #{t 'blank_in_es.a'}
p = t 'used_but_missing.key'
p = t 'missing-key-with-a-dash.key'
p = t 'x', scope: 'scoped'
p = t 'x', scope: [:very, :scoped]
p = t 'x', scope: [:scoped, code]
Expand Down
4 changes: 3 additions & 1 deletion spec/i18n_tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
es.missing_in_es.a es.same_in_es.a
en.hash.pattern_missing.a en.hash.pattern_missing.b
en.missing_symbol_key en.missing_symbol.key_two en.missing_symbol.key_three
es.missing_in_es_plural_1.a es.missing_in_es_plural_2.a)
es.missing_in_es_plural_1.a es.missing_in_es_plural_2.a
en.missing-key-with-a-dash.key
)
}
it 'detects missing or identical' do
capture_stderr do
Expand Down

0 comments on commit ac94281

Please sign in to comment.