dynamic_sitemaps
dynamic_sitemaps copied to clipboard
Add Scopes
Hello,
I have a bilingual site. It can be useful to add a scope and to something like this sitemap_for Page.scoped, scope: ['en', 'fr'].
What you think?
Just to know, this is the code I created to do what I want :
def sitemap_with_locales_for(records, method)
sitemap_for records do |model|
I18n.available_locales.each do |locale|
I18n.locale = locale
url send(method, model, locale: locale), last_mod: model.updated_at,
priority: 1.0
end
end
end
prev_locale = I18n.locale
sitemap_with_locales_for(Page.scoped, :page_url)
sitemap_with_locales_for(ProviderProfile.provider_profiles_with_pages, :provider_profile_url)
sitemap_with_locales_for(Artist.all_artists_with_paintings, :artist_url)
I18n.locale = prev_locale