mirror of
https://github.com/discourse/discourse.git
synced 2024-12-24 06:45:03 +08:00
319075e4dd
* FIX: Ensure JsLocaleHelper to obly outputs up-to-date translations The old implementation forgot to filter out deprecated translations, causing these translations to incorrectly override the new locale in the frontend. This commit fills in the forgotten where clause, filtering only the up-to-date part. Related meta topic: https://meta.discourse.org/t/outdated-translation-replacement-causing-missing-translation/314352
14 lines
309 B
Ruby
14 lines
309 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
|