Problem with field name localizations

We have problem with field localizations:

As you see in the image above the fields doesn’t read the localization. Translations/localizations exist in the resx files for each language/culture but they still doesn’t fetch them.

The strange part is that this works fine localy but not on our test or preflight/prod environment.

The implementation of InitFields() looks as below:

private void InitFields(IEnumerable<FieldDefinition> fields)
        {
            foreach (var item in fields)
            {
                var currentField = _fieldDefinitionService.Get(item.AreaType, item.Id);
                if (currentField == null)
                {
                    if (IsAlreadyExecuted<RelationshipType>(item.Id))
                    {
                        continue;
                    }
                    _fieldFrameworkSetupLocalizationService.Localize(item);
                    _fieldDefinitionService.Create(item);
                    currentField = _fieldDefinitionService.Get(item.AreaType, item.Id);
                }
                else
                {
                    currentField = currentField.MakeWritableClone();
                    if (item.FieldType != currentField.FieldType)
                    {
                        currentField.FieldType = item.FieldType;
                    }

                    _fieldFrameworkSetupLocalizationService.Localize(currentField);
                    _fieldDefinitionService.Update(currentField);
                }

                if (item.MultiCulture != currentField.MultiCulture)
                {
                    this.Log().Error($"Accelerator \"{item.Id}\" field with \"MultiCulture\" setting and \"{item.MultiCulture}\" value can't be created. The system already has the \"{currentField.Id}\" field with \"MultiCulture\" setting and \"{currentField.MultiCulture}\" value. Accelerator deployment would fail.");
                    continue;
                }

                SetAlreadyExecuted<FieldDefinition>(item.Id, item.AreaType.Name);
            }
        }

What could cause this problem?

Litium version: [7.4.2]

Do you have the same DB locally and on the server?

no, different dbs on different servers. Test and preflight are hosted by Litium.

Ok when the fields were created there maybe were no translations so you will need to remove those fields and restart the application again, important that you clear the Common.Settings table related rows before doing that otherwise they will not get created.

Ok, but shouldn’t the else-statement in InitFields() do it at the next startup?

else
                {
                    currentField = currentField.MakeWritableClone();
                    if (item.FieldType != currentField.FieldType)
                    {
                        currentField.FieldType = item.FieldType;
                    }

                    _fieldFrameworkSetupLocalizationService.Localize(currentField);
                    _fieldDefinitionService.Update(currentField);
                }

_fieldFrameworkSetupLocalizationService.Localize(currentField); isn’t this line for that?

Not sure if you can set the localization after the field has already been created.

that theory is not true because this problem applies to all fields, filedGroup names, fieldTemplateNames etc except SystemFieldDefinitions (the fields those their definitions are not in the accelerator). And removing all fields in hope that traslation will appear is not a solution.

Are the resource files delivered to the server?

nope they were not, somehow they have got wrong “Build Action” property but they were included in the project. Many thanks for the help.

You can add that it will update the field translation during startup when it checks the fields, i have done it a few times to save development time. One thing to remember is that it will obviously overwrite if anything is set via BO. You could extend it that it will only update when empty or it contains the namespace.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.