FEATURE: add Untranslated filter to admin text customization (#27555)

Adds a checkbox to filter untranslated text strings in the admin UI, behind a hidden and default `false` site setting `admin_allow_filter_untranslated_text`.
This commit is contained in:
Renato Atilio
2024-06-24 06:24:06 -03:00
committed by GitHub
parent ce00f83173
commit 55da8a7701
8 changed files with 91 additions and 6 deletions

View File

@@ -187,6 +187,34 @@ RSpec.describe Admin::SiteTextsController do
expect(value).to eq("education.new-topic override")
end
it "returns only untranslated (english) strings" do
available_locales = I18n.config.available_locales
I18n.config.available_locales = %i[en test]
I18n.backend.store_translations(:en, { shrubbery: "Shrubbery" })
I18n.backend.store_translations(:en, { shrubbery2: "Shrubbery2" })
params = { q: "shrubbery", locale: "test", untranslated: "true" }
get "/admin/customize/site_texts.json", params: params
expect(response.status).to eq(200)
expect(response.parsed_body["site_texts"].size).to eq(2)
I18n.backend.store_translations(:test, { shrubbery: "Arbusto" })
get "/admin/customize/site_texts.json", params: params
expect(response.status).to eq(200)
expect(response.parsed_body["site_texts"].size).to eq(1)
TranslationOverride.upsert!(:test, "shrubbery2", "Arbusto2")
get "/admin/customize/site_texts.json", params: params
expect(response.status).to eq(200)
expect(response.parsed_body["site_texts"].size).to eq(0)
I18n.config.available_locales = available_locales
end
context "with plural keys" do
before do
I18n.backend.store_translations(