How to handle nested language partitions in C#

What I tried to achieve is to store nested component with partitioned fields for description, so only description should be localizable not other fields.

When I pass Dictionary<string,string> I’m getting error that even if field is localizable it’s expected as a string only.

var componentSchemaDto = new CreateSchemaDto
{
    Name = name,
    Fields = new List<UpsertSchemaFieldDto>
    {
        new()
        {
            Name = nameof(Description),
            Properties = new StringFieldPropertiesDto(),
            Partitioning = Partitioning.Language
        },
		 new()
        {
            Name = nameof(TenantId),
            Properties = new NumberFieldPropertiesDto()
        }
		...
    },
    Scripts = scripts,
    Properties = new SchemaPropertiesDto { ValidateOnPublish = true },
    IsPublished = true,
    Type = SchemaType.Component
};

and main schema

var createSchemaDto = new CreateSchemaDto
{
    Name = name,
    Fields = new List<UpsertSchemaFieldDto>
    {
        new()
        {
            Name = nameof(Content),
            Properties = new ComponentFieldPropertiesDto()
            {
                SchemaIds = new List<string> { "56a7d2cb-8ad3-47b3-b0ee-2c674723adf9" } // get this from squidex
            }
        },
        new()
        {
            Name = nameof(Tags),
            Properties = new TagsFieldPropertiesDto()
        }},
    Scripts = scripts,
    Properties = new SchemaPropertiesDto { ValidateOnPublish = true},
    IsPublished = true,
    Type = SchemaType.Default,
};

and in model I’m using Dictionary for localizable field for Content component.

Is this proper way to set it up or I’m doing something wrong? Does localization works on component fields?

Hi,

at the moment components are always flat. They share the same structures as schemas, but the partitioning is ignored for them.

So unfortunately your requirement is not really possible as of now.

1 Like

Thanks for clarification!

Just for planning ahead, is it planned to be supported in the future?

Br, Bojan

I am not sure, it is just so complicated. You can have two levels of localization and I am not sure if this makes sense for content editors and for the UI.

This was always the main reason, not like technical complexity.