mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
FIX: Don't show admin warnings about deleted translation overrides (#22614)
We recently introduced this advice to admins when some translation overrides are outdated or using unknown interpolation keys: However we missed the case where the original translation key has been renamed or altogether removed. When this happens they are no longer visible in the admin interface, leading to the confusing situation where we say there are outdated translations, but none are shown. Because we don't explicitly handle this case, some deleted translations were incorrectly marked as having unknown interpolation keys. (This is because I18n.t will return a string like "Translation missing: foo", which obviously has no interpolation keys inside.) This change adds an additional status, deprecated for TranslationOverride, and the job that checks them will check for this status first, taking precedence over invalid_interpolation_keys. Since the advice only checks for the outdated and invalid_interpolation_keys statuses, this fixes the problem.
This commit is contained in:
@ -284,6 +284,28 @@ RSpec.describe TranslationOverride do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#original_translation_deleted?" do
|
||||
context "when the original translation still exists" do
|
||||
fab!(:translation) { Fabricate(:translation_override, translation_key: "title") }
|
||||
|
||||
it { expect(translation.original_translation_deleted?).to eq(false) }
|
||||
end
|
||||
|
||||
context "when the original translation has been turned into a nested key" do
|
||||
fab!(:translation) { Fabricate(:translation_override, translation_key: "title") }
|
||||
|
||||
before { translation.update_attribute("translation_key", "dates") }
|
||||
|
||||
it { expect(translation.original_translation_deleted?).to eq(true) }
|
||||
end
|
||||
|
||||
context "when the original translation no longer exists" do
|
||||
fab!(:translation) { Fabricate(:translation_override, translation_key: "foo.bar") }
|
||||
|
||||
it { expect(translation.original_translation_deleted?).to eq(true) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#original_translation_updated?" do
|
||||
context "when the translation is up to date" do
|
||||
fab!(:translation) { Fabricate(:translation_override, translation_key: "title") }
|
||||
|
Reference in New Issue
Block a user