mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 15:24:14 +08:00
1f5cbb9a44
This is a small followup of https://github.com/discourse/discourse/pull/28037.
14 lines
310 B
Ruby
14 lines
310 B
Ruby
# frozen_string_literal: true
|
|
|
|
class I18nInterpolationKeysFinder
|
|
def self.find(text)
|
|
return [] unless text.is_a?(String)
|
|
pattern = Regexp.union([*I18n.config.interpolation_patterns, /\{\{(\w+)\}\}/])
|
|
keys = text.scan(pattern)
|
|
keys.flatten!
|
|
keys.compact!
|
|
keys.uniq!
|
|
keys
|
|
end
|
|
end
|