OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.33k stars 2.36k forks source link

Localization of Custom Settings ContentType by LocalizationPart #15237

Open bashuss opened 6 months ago

bashuss commented 6 months 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 https://github.com/OrchardCMS/OrchardCore/discussions/14908

To Reproduce

Steps to reproduce the behavior

  1. From Backend create a ContentType with CustomSettings stereotype, add the Localization ContentPart, add some Fields, save it.
  2. Open the corresponding Settings-Page in Backend-Configuration-Settings
  3. On top of the settings page you will find the localization dropdown indicating default culture of you site.
  4. Save the settings in your default culture, then select another configured culture from the dropdown and try to add it
  5. 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

image image
sebastienros commented 6 months ago

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.

hishamco commented 6 months ago

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

sebastienros commented 6 months ago

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.

hishamco commented 6 months ago

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?

hishamco commented 6 months ago

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

sebastienros commented 6 months ago

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.

hishamco commented 6 months ago

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

  1. in the OrchardCore.Settings by adding property per culture or we might think of managing the localized settings in a different table
ashrafsabrym commented 6 months ago

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.

image

hishamco commented 6 months ago

@ashrafsabrym this need a design

ashrafsabrym commented 5 months ago

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: image

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.

hishamco commented 5 months ago

I think there's issue or not supported yet, I remember @urbanit addressed that long time ago

DotCat1985 commented 2 months 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

  1. From Backend create a ContentType with CustomSettings stereotype, add the Localization ContentPart, add some Fields, save it.
  2. Open the corresponding Settings-Page in Backend-Configuration-Settings
  3. On top of the settings page you will find the localization dropdown indicating default culture of you site.
  4. Save the settings in your default culture, then select another configured culture from the dropdown and try to add it
  5. 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

image image

I've the same problem.