mirror of
https://github.com/discourse/discourse.git
synced 2026-03-03 23:54:20 +08:00
This PR adds category localization support to core. - Depends on https://github.com/discourse/discourse/pull/32378 - Creates the required table `category_localizations` - Makes use of the site category cache to display localized categories - Supports name and description - This does not yet include /categories page. (coming in a next PR) ## Before <img width="1089" alt="Screenshot 2025-04-21 at 4 31 43 PM" src="https://github.com/user-attachments/assets/9e49b21b-b16a-43d2-9b16-0fd0324a21ca" /> ## After <img width="1085" alt="Screenshot 2025-04-21 at 4 32 42 PM" src="https://github.com/user-attachments/assets/7bfa21a2-6df2-4cdf-a00a-d044c3526a40" />
29 lines
907 B
Ruby
29 lines
907 B
Ruby
# frozen_string_literal: true
|
|
|
|
describe CategoryLocalization do
|
|
context "when commit" do
|
|
it "clears the site cache for the locale" do
|
|
category = Fabricate(:category, name: "yy")
|
|
|
|
I18n.locale = "es"
|
|
expect(Site.all_categories_cache.pluck(:name)).to include("yy")
|
|
|
|
I18n.locale = "en"
|
|
expect(Site.all_categories_cache.pluck(:name)).to include("yy")
|
|
|
|
category.update_columns(name: "zz")
|
|
|
|
I18n.locale = "es"
|
|
expect(Site.all_categories_cache.pluck(:name)).to include("yy")
|
|
I18n.locale = "en"
|
|
expect(Site.all_categories_cache.pluck(:name)).to include("yy")
|
|
|
|
Fabricate(:category_localization, name: "Japón", locale: "es", category:)
|
|
|
|
I18n.locale = "es"
|
|
expect(Site.all_categories_cache.pluck(:name)).to include("zz")
|
|
I18n.locale = "en"
|
|
expect(Site.all_categories_cache.pluck(:name)).to include("yy")
|
|
end
|
|
end
|
|
end
|