Translations for property that stores its data as an array aren't applied correctly
I have a custom property that stores its data as json. I wrote a mapper for it and that's working, but I'm running into issues with handing its value off to the NestedContentMapper, since it appears to expect its inner mappers to return strings, as I get the following error.
2019-02-25 13:09:35,014 [P8868/D23/T23] ERROR Jumoo.TranslationManager.Core.Controllers.TranslationJobApiController - Unhandled controller exception occurred
System.InvalidCastException: Unable to cast object of type 'System.Collections.Generic.List`1[FlexibleLinkV2.Models.FlexibleLinkModel]' to type 'System.String'.
at Jumoo.TranslationManager.Core.ValueMappers.NestedContentMapper.GetTargetValue(String propertyEditorAlias, Object sourceValue, TranslationValue value, CultureInfoView sourceCulture, CultureInfoView targetCulture)
at Jumoo.TranslationManager.Core.ValueMappers.LeBlenderValueMapper.GetTargetValue(String propertyTypeAlias, Object sourceValue, TranslationValue values, CultureInfoView sourceCulture, CultureInfoView targetCulture)
at Jumoo.TranslationManager.Core.ValueMappers.GridValueMapper.GetTargetValue(String propertyEditorAlias, Object sourceValue, TranslationValue value, CultureInfoView sourceCulture, CultureInfoView targetCulture)
at Jumoo.TranslationManager.Core.Services.TranslationValueService.SetPropertyValue(IContent item, String alias, String sourceValue, TranslationValue value, CultureInfoView sourceCulture, CultureInfoView targetCulture)
at Jumoo.TranslationManager.Core.Services.TranslationNodeService.SetContentValuesFromTranslation(TranslationNode node, CultureInfoView sourceCulture)
at Jumoo.TranslationManager.Core.Services.TranslationJobService.ProgressJob(TranslationJob job, IEnumerable`1 nodes, Boolean publish, Boolean ApproveJob, Boolean checkProgress)
at Jumoo.TranslationManager.Core.Services.TranslationJobService.ProgressJob(TranslationJob job, IEnumerable`1 nodeIds, Boolean publish, Boolean ApproveJob, Boolean checkProgress)
at Jumoo.TranslationManager.Core.Controllers.TranslationJobApiController.Approve(Int32 id, ApproveOptions options)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
The data returned by the mapper I wrote is in the form:
in umbraco.config if I serialize the data to avoid the error.
Can you add a check to NestedContentMapper to avoid the earlier error and ensure that the unescaped data is returned? If it still encodes it after that, the issue could be that the nested content is nested inside a leblender control.
Turns out things weren't working because of a serialization issue, since the property names were stored in PascalCase instead of CamelCase. This prevented angular from picking up on the data. Umbraco parses the text correctly.
Glad you sorted it. - but just a note to say how it works in case it helps.
The idea behind the translation values and inner values is that they only contain the text needed to be translated - and the other elements and settings - are kept on the content nodes. so as such if you have a custom object that has the following items :
When it comes to serializing this back - it would be the custom mappers responsibility to return the JSON that would go into the content element - (there is an added complication on how JSON is stored inside leblender inside nested content - but for most of the time should work)
As an aside - if your custom object is storing json and doing nothing to fancy you can configure that mapper using the custom mapper config.
Yeah I had tried that at one point, but the control I was working on at the time didn't work with this, as it had a grid control nested inside it, so I hadn't pursued this approach further. I'll keep it in mind though, as you are right that it should work for the control I shared with you.
Translations for property that stores its data as an array aren't applied correctly
I have a custom property that stores its data as json. I wrote a mapper for it and that's working, but I'm running into issues with handing its value off to the NestedContentMapper, since it appears to expect its inner mappers to return strings, as I get the following error.
The data returned by the mapper I wrote is in the form:
but it's stored as
in umbraco.config if I serialize the data to avoid the error.
Can you add a check to NestedContentMapper to avoid the earlier error and ensure that the unescaped data is returned? If it still encodes it after that, the issue could be that the nested content is nested inside a leblender control.
Turns out things weren't working because of a serialization issue, since the property names were stored in PascalCase instead of CamelCase. This prevented angular from picking up on the data. Umbraco parses the text correctly.
Hi Jesse,
Glad you sorted it. - but just a note to say how it works in case it helps.
The idea behind the translation values and inner values is that they only contain the text needed to be translated - and the other elements and settings - are kept on the content nodes. so as such if you have a custom object that has the following items :
in translation manager, this would be represented by (assuming type is text)
TranslationValue (your custom value) - Inner Values - Translation Value (Label) ["A Label"] - Translation Value (Type) ["Internal"]
So the item passed back to Nested Content Mapper would be the translation value (custom value).
you can see this: in our sample code here: https://gist.github.com/KevinJump/a7754bb20f93b1e9934a8cbfb1bb9203
When it comes to serializing this back - it would be the custom mappers responsibility to return the JSON that would go into the content element - (there is an added complication on how JSON is stored inside leblender inside nested content - but for most of the time should work)
As an aside - if your custom object is storing json and doing nothing to fancy you can configure that mapper using the custom mapper config.
Yeah I had tried that at one point, but the control I was working on at the time didn't work with this, as it had a grid control nested inside it, so I hadn't pursued this approach further. I'll keep it in mind though, as you are right that it should work for the control I shared with you.
is working on a reply...