alchemy_cms
alchemy_cms copied to clipboard
sitemap generation for multi-language websites does not write out correct urls
Steps to reproduce
- Create a multi-language website, let's say the default language is fr and the alternative language is en.
- Create a few pages in each website.
- In config/initializers/locale.rb set
I18n.default_locale = :fr - Check /sitemap.xml
- In config/initializers/locale.rb set
I18n.default_locale = :en - Check /sitemap.xml
Expected behavior
Links for the non-default language should be prefixed with the correct language, /en/ or /fr/. The sitemaps should not depend on the setting in locale.rb.
Actual behavior
Depending on the setting in locale.rb no links are prefixed, sitemap points to non-existing pages.
Proposed solution
I think helpers/alchemy/url_helper.rb:28 should call prefix_locale?(page.language_code) instead of just prefix_locale?. Otherwise it ends up using Language.current&.code.
System configuration
- Alchemy Version: 2.0.5
- Rails Version: 6.0.0