Skip to content

Commit

Permalink
22041 when checking for "inconsistent interpolations" also check for …
Browse files Browse the repository at this point in the history
…"unrestored interpolations" (which is just a fancy name for translation texts that have '!!!!!' in them - the new restore interpolations method outputs !!!!! when it fails to restore correctly)

References bookingexperts/support#22041
  • Loading branch information
barak-neeman committed Aug 12, 2024
1 parent 5c48708 commit 198684c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/i18n/tasks/interpolations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,27 @@ def inconsistent_interpolations(locales: nil, base_locale: nil) # rubocop:disabl
end
end

result.merge!(unrestored_interpolations(locales: locales))
result.each { |root| root.data[:type] = :inconsistent_interpolations }
result
end

def unrestored_interpolations(locales: nil)
locales ||= self.locales
result = empty_forest

locales.each do |locale|
data[locale].key_values.each do |key, value|
next unless value.is_a?(String)
next unless value.index('!!!!!')

node = Data::Tree::Node.new(key: key, value: value)
result.set(key, node)
end
end
result
end

def get_normalized_variables_set(string)
Set.new(string.scan(I18n::Tasks::Interpolations.variable_regex).map { |variable| normalize(variable) })
end
Expand Down

0 comments on commit 198684c

Please sign in to comment.