[MULTISITE-120] Locale aware MultiSiteRegexpVirtualURIMapping Created: 30/Nov/17 Updated: 18/May/22 |
|
| Status: | Open |
| Project: | Magnolia Multisite Module |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Samuel Zihlmann | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Template: |
|
||||||||
| Acceptance criteria: |
Empty
|
||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||
| Date of First Response: | |||||||||
| Visible to: |
Peter Mohn
|
||||||||
| Team: | |||||||||
| Description |
|
With MultiSiteRegexpVirtualURIMapping, the URI is always mapped to the default language, which ist not desirable in a multilingual environment and renders MultiSiteRegexpVirtualURIMapping effectively useless in many cases. An example:
This seems like a very basic feature that should be provided by Magnolia itself. We built the following workaround for our project: public class LocaleAwareMultiSiteRegexpVirtualURIMapping extends MultiSiteRegexpVirtualURIMapping { @Inject public LocaleAwareMultiSiteRegexpVirtualURIMapping(SiteProvider siteProvider) { super(siteProvider); } @Override public MappingResult mapURI(final String uri, String queryString) { MappingResult r = super.mapURI(uri, queryString); if (r != null) { String replaced = r.getToURI().replace("{locale}", getLocale()); r.setToURI(replaced); } return r; } private String getLocale() { I18nContentSupport i18nSupport = Components.getComponent(I18nContentSupport.class); return i18nSupport.getLocale().getLanguage(); } } This works fine for now, but it would be great if such a feature could be incorporated into Magnolia in a future version. |