From 5279b0f553406ef63a28e92051ebd0c02c6fdd23 Mon Sep 17 00:00:00 2001 From: Barak Neeman Date: Mon, 12 Aug 2024 12:34:15 -0600 Subject: [PATCH] 22041 when checking for "inconsistent interpolations" also check for "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 --- lib/i18n/tasks/interpolations.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/i18n/tasks/interpolations.rb b/lib/i18n/tasks/interpolations.rb index a25dd045..09e51f6e 100644 --- a/lib/i18n/tasks/interpolations.rb +++ b/lib/i18n/tasks/interpolations.rb @@ -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.include?('!!!!!') + + 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