OrchardCore
OrchardCore copied to clipboard
Localization of Custom Settings ContentType by LocalizationPart
Describe the bug
Using a Custom Settings ContentType, which contains the localization ContentPart, it is not possible to add a localized version of the settings. Instead you get a "The page could not be found." message with the URL /Admin/ContentLocalization
Previous discussion about the bug https://github.com/OrchardCMS/OrchardCore/discussions/14908
To Reproduce
Steps to reproduce the behavior
- From Backend create a ContentType with CustomSettings stereotype, add the Localization ContentPart, add some Fields, save it.
- Open the corresponding Settings-Page in Backend-Configuration-Settings
- On top of the settings page you will find the localization dropdown indicating default culture of you site.
- Save the settings in your default culture, then select another configured culture from the dropdown and try to add it
- you will see: "The page could not be found." message with the URL /Admin/ContentLocalization
Expected behavior
The settings page should be shown with a localized version of the settings to be edited an saved.
Screenshots
Maybe the controller for the custom settings needs to be made localization-aware.
In the Settings feature, the controller might need to accept a culture argument to edit this specific instance.
This happens because the content item is saved in OrchardCore.Settings
, so there's no content item will be added in both ContentItemIndex
or LocalizedContentItemIndex
does it really have something to do with the indexes? The settings is a sub property named by its type. It just needs to have another level of indirection by culture, and fetch it differently.
The settings is a sub property named by its type. It just needs to have another level of indirection by culture, and fetch it differently.
I thought about that, but there's a localized set that should be in the index, right?
Even if we add culture as a level when we try to localize the content the localized link will throw an exception because the controller looks for the content item id
This might be need a discussion
a localized set that should be in the index, right
Custom Settings are not managed like other content items. They are not documents that are indexed. We just serialize them as a json property of the unique CustomSettings
. Check CustomSettingsService.GetSettingsAsync
. It will deserialize a ContentItem
manually, not using the store (and indexes).
This service should be extended to provide a localization argument, such that the UI can have a drop down to select which culture we want to edit the settings for, and also to load a specific setting for the current culture.
This will probably also require a migration to move existing settings in an array, in case we want each localized content item to be seekable by its LocalizationSet/ILocalizedPart properties.
Custom Settings are not managed like other content items. They are not documents that are indexed. We just serialize them as a json property of the unique CustomSettings. Check CustomSettingsService.GetSettingsAsync. It will deserialize a ContentItem manually, not using the store (and indexes).
I'm aware of the difference here, what I'd like to say is that the localized versions are managed differently, in the case of CustomSettings we might need to manage the cultures either
- in the
OrchardCore.Settings
by adding property per culture or we might think of managing the localized settings in a different table
I have an issue similar to this. I have modeled the categories in my website after those in TheBlogTheme
, with one difference which is that I've added content localization part to my Category content type.
I have created a Category content item, then tried to create localizations for it, and I get the same Not Found page.
I've attached a debugger while doing the action, and in this line in AdminController.cs, contentItem
is null
.
The controller tries to fetch an item not created yet.
@ashrafsabrym this need a design
I noticed that taxonomy terms are not stored as content items, so they don't have records in contentitemindex
, they are just stored in the document of their parent taxonomy, so they can't be localized. I thought I'm doing it wrong, so I removed the localization part from the taxonomy terms type and placed it in the taxonomy type. I ended with three taxonomy items, but can't use any of them because in my product type definition, I have to pick one:
The scenario I want to achieve is localizable taxonomies/categories with their localized URLs ({{ Model.ContentItem.Content.LocalizationPart.Culture }}/{{ "products-categories" | t }}
) that can be used with my localized product catalog. This scenario is not currently achievable, and I couldn't find any sample that resembles what I'm trying to do.
I think there's issue or not supported yet, I remember @urbanit addressed that long time ago
Describe the bug
Using a Custom Settings ContentType, which contains the localization ContentPart, it is not possible to add a localized version of the settings. Instead you get a "The page could not be found." message with the URL /Admin/ContentLocalization
Previous discussion about the bug #14908
To Reproduce
Steps to reproduce the behavior
- From Backend create a ContentType with CustomSettings stereotype, add the Localization ContentPart, add some Fields, save it.
- Open the corresponding Settings-Page in Backend-Configuration-Settings
- On top of the settings page you will find the localization dropdown indicating default culture of you site.
- Save the settings in your default culture, then select another configured culture from the dropdown and try to add it
- you will see: "The page could not be found." message with the URL /Admin/ContentLocalization
Expected behavior
The settings page should be shown with a localized version of the settings to be edited an saved.
Screenshots
![]()
I've the same problem.