FIX: Detect {{foo}} as interpolation key

This commit is contained in:
Gerhard Schlager 2018-09-04 12:01:29 +02:00
parent c788737eed
commit b8fc699164
2 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
class I18nInterpolationKeysFinder
def self.find(text)
keys = text.scan(I18n::INTERPOLATION_PATTERN)
keys = text.scan(Regexp.union(I18n::INTERPOLATION_PATTERN, /\{\{(\w+)\}\}/))
keys.flatten!
keys.compact!
keys.uniq!

View File

@ -4,8 +4,8 @@ require "i18n/i18n_interpolation_keys_finder"
RSpec.describe I18nInterpolationKeysFinder do
describe '#find' do
it 'should return the right keys' do
expect(described_class.find('%{first} %{second}'))
.to eq(['first', 'second'])
expect(described_class.find('%{first} %{second} {{third}}'))
.to eq(['first', 'second', 'third'])
end
end
end