diff --git a/lib/i18n/tasks/scanners/base_scanner.rb b/lib/i18n/tasks/scanners/base_scanner.rb index 14171f0a..6212b798 100644 --- a/lib/i18n/tasks/scanners/base_scanner.rb +++ b/lib/i18n/tasks/scanners/base_scanner.rb @@ -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) diff --git a/spec/fixtures/app/views/index.html.slim b/spec/fixtures/app/views/index.html.slim index eb219497..ebd51fac 100644 --- a/spec/fixtures/app/views/index.html.slim +++ b/spec/fixtures/app/views/index.html.slim @@ -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] diff --git a/spec/i18n_tasks_spec.rb b/spec/i18n_tasks_spec.rb index 017db65a..c95976e7 100644 --- a/spec/i18n_tasks_spec.rb +++ b/spec/i18n_tasks_spec.rb @@ -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