From 4b3f653ed78397daa1407907c5405c148462f784 Mon Sep 17 00:00:00 2001 From: eelco Date: Thu, 5 Feb 2026 11:45:43 +0700 Subject: [PATCH] I18n/locales exploration --- lib/perron/collection.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/perron/collection.rb b/lib/perron/collection.rb index a14281f..568da3d 100644 --- a/lib/perron/collection.rb +++ b/lib/perron/collection.rb @@ -38,12 +38,18 @@ def validate = Perron::Site::Validate.new(collections: [self]).validate private - def load_resources(resource_class = "Content::#{name.classify}".safe_constantize) + def load_resources(resource_class = "Content::#{name.classify}".safe_constantize, locale: I18n.locale.to_s) allowed_extensions = Perron.configuration.allowed_extensions.map { ".#{it}" }.to_set - Dir.glob("#{@collection_path}/**/*.*") + Dir.glob("#{collection_path}/**/*.*") .select { allowed_extensions.include?(File.extname(it)) } .map { resource_class.new(it) } end + + def collection_path + locale_path = "#{@collection_path}/#{I18n.locale.to_s}" + + Dir.exist?(locale_path) ? locale_path : @collection_path + end end end