OrchardCore icon indicating copy to clipboard operation
OrchardCore copied to clipboard

Localization of Custom Settings ContentType by LocalizationPart

Open bashuss opened this issue 1 year ago • 12 comments

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

bashuss avatar Feb 02 '24 10:02 bashuss

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.

sebastienros avatar Feb 08 '24 19:02 sebastienros

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

hishamco avatar Feb 08 '24 21:02 hishamco

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.

sebastienros avatar Feb 08 '24 21:02 sebastienros

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 avatar Feb 08 '24 22:02 hishamco

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

hishamco avatar Feb 08 '24 22:02 hishamco

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.

sebastienros avatar Feb 15 '24 18:02 sebastienros

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

hishamco avatar Feb 16 '24 00:02 hishamco

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

ashrafsabrym avatar Feb 27 '24 21:02 ashrafsabrym

@ashrafsabrym this need a design

hishamco avatar Feb 27 '24 22:02 hishamco

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.

ashrafsabrym avatar Mar 26 '24 08:03 ashrafsabrym

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

hishamco avatar Mar 27 '24 01:03 hishamco

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.

DotCat1985 avatar Jun 17 '24 06:06 DotCat1985