discourse/app/jobs/scheduled/check_translation_overrides.rb
锦心 319075e4dd
FIX: Ensure JsLocaleHelper to not output deprecated translations ()
* 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
2024-07-29 15:21:25 +08:00

28 lines
842 B
Ruby

# frozen_string_literal: true
module Jobs
class CheckTranslationOverrides < ::Jobs::Scheduled
every 1.day
def execute(args)
deprecated_ids = []
invalid_ids = []
outdated_ids = []
TranslationOverride.find_each do |override|
if override.original_translation_deleted?
deprecated_ids << override.id
elsif override.invalid_interpolation_keys.present?
invalid_ids << override.id
elsif override.original_translation_updated?
outdated_ids << override.id
end
end
TranslationOverride.where(id: outdated_ids).update_all(status: "outdated")
TranslationOverride.where(id: invalid_ids).update_all(status: "invalid_interpolation_keys")
TranslationOverride.where(id: deprecated_ids).update_all(status: "deprecated")
end
end
end