discourse/lib/i18n/i18n_interpolation_keys_finder.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

14 lines
309 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class I18nInterpolationKeysFinder
def self.find(text)
return [] unless text.is_a? String
2020-08-03 21:57:29 +08:00
pattern = Regexp.union([*I18n.config.interpolation_patterns, /\{\{(\w+)\}\}/])
keys = text.scan(pattern)
keys.flatten!
keys.compact!
keys.uniq!
keys
end
end