discourse/lib/i18n/i18n_interpolation_keys_finder.rb
2024-07-30 09:56:46 +08:00

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