Basically, it allows you to create your pages in your default language (say, English), then it creates a subnode under each page called "Translations" and under that are nodes particular to each language that you translate to. Using some URL rewrites and conditional checks to look for child nodes, the content with the appropriate language will be shown (it falls back to the default language if no translation exists).
Is there any easy way to make Ditto map content structured in this way?
My guess is I'd just have to choose which node to use (e.g., the current page or one of the child translations) and map that. However, then I couldn't do fallbacks for particular properties (i.e., I'd be stuck with one node... all or nothing).
What I'm hoping is that the code in Ditto that calls "GetPropertyValue" is swappable (e.g., perhaps I can have it call my "LocalizedPropertyValue" alternative).
In order to use your LocalizedPropertyValue, you'd need to write your own ValueResolver (probably just copy the UmbracoPropertyValueResolver one) and replace accordingly.
Here's a similar example of how James South tackled this when using Vorto property-values:
One thing to note about ValueResolvers... in the next version of Ditto, they are being replaced by a new approach called Processors. (Think of it as a combination of ValueResolvers and TypeConverters), there's a whole discussion around it on GitHub:
https://github.com/leekelleher/umbraco-ditto/pull/143
If I'm reading the documentation on value resolvers correctly, I'd have to decorate each of my properties with my value resolver. I was hoping for more of a pipeline solution (e.g., the ability to swap out the default value resolver so it always knows the use my international version).
Ditto with Polyglot?
I typically build my international sites with a tool called Polyglot: https://our.umbraco.org/projects/backoffice-extensions/polyglot/
Basically, it allows you to create your pages in your default language (say, English), then it creates a subnode under each page called "Translations" and under that are nodes particular to each language that you translate to. Using some URL rewrites and conditional checks to look for child nodes, the content with the appropriate language will be shown (it falls back to the default language if no translation exists).
Is there any easy way to make Ditto map content structured in this way?
My guess is I'd just have to choose which node to use (e.g., the current page or one of the child translations) and map that. However, then I couldn't do fallbacks for particular properties (i.e., I'd be stuck with one node... all or nothing).
What I'm hoping is that the code in Ditto that calls "GetPropertyValue" is swappable (e.g., perhaps I can have it call my "LocalizedPropertyValue" alternative).
Hi Nicholas,
I haven't used Polyglot myself, so not sure of the finer details.
In terms of swapping out
GetPropertyValue
calls with yourLocalizedPropertyValue
call, it is possible.The only place that we use
GetPropertyValue
is in the mainUmbracoPropertyValueResolver
(along with theUmbracoPropertyValue
attribute), see here:https://github.com/leekelleher/umbraco-ditto/blob/master/src/Our.Umbraco.Ditto/ComponentModel/ValueResolvers/UmbracoPropertyValueResolver.cs#L70
In order to use your
LocalizedPropertyValue
, you'd need to write your own ValueResolver (probably just copy theUmbracoPropertyValueResolver
one) and replace accordingly.Here's a similar example of how James South tackled this when using Vorto property-values:
https://gist.github.com/JimBobSquarePants/80762a1233bbb112689e#file-vortovalueresolver-cs
I hope this helps?
Cheers,
- Lee
If I'm reading the documentation on value resolvers correctly, I'd have to decorate each of my properties with my value resolver. I was hoping for more of a pipeline solution (e.g., the ability to swap out the default value resolver so it always knows the use my international version).
Yes, that's correct. Currently the default one (
UmbracoProperty
) can't be over replaced.Feel free to open an issue on our GitHub repo, we can discuss further (and be good to get Matt and James's views on it too)
Thanks, - Lee
Done: https://github.com/leekelleher/umbraco-ditto/issues/151
Cool, thanks Nicholas!
is working on a reply...