Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization of Custom Settings ContentType by LocalizationPart #15237

Open
bashuss opened this issue Feb 2, 2024 · 12 comments
Open

Localization of Custom Settings ContentType by LocalizationPart #15237

bashuss opened this issue Feb 2, 2024 · 12 comments
Assignees
Milestone

Comments

@bashuss
Copy link

bashuss commented Feb 2, 2024

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
@sebastienros sebastienros added this to the 1.x milestone Feb 8, 2024
@sebastienros
Copy link
Member

sebastienros commented Feb 8, 2024

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 hishamco self-assigned this Feb 8, 2024
@hishamco
Copy link
Member

hishamco commented Feb 8, 2024

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
Copy link
Member

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
Copy link
Member

hishamco commented Feb 8, 2024

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
Copy link
Member

hishamco commented Feb 8, 2024

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
Copy link
Member

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
Copy link
Member

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
Copy link

ashrafsabrym commented Feb 27, 2024

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
Copy link
Member

@ashrafsabrym this need a design

@ashrafsabrym
Copy link

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
Copy link
Member

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

@DotCat1985
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants