babel
babel copied to clipboard
Use modResource->duplicate instead of manually creating a copy in Babel->duplicateResource to support CRCs
This code handles duplicating the resources for translation, however that causes issues with custom resource classes like SimpleCart.
SimpleCart stores some of its information (product code, price and image etc) in a separate table, and its custom resource class has an extended duplicate() method that takes care of copying that information across. Unfortunately, because Babel doesn't call the duplicate() method, users need to re-enter the product information on a translation.
Understandably Babel may do more with the resource copy than modResource->duplicate allows out of the box, but as that method returns the new resource I think it should still be possible to handle Babel stuff after a call to duplicate().
[Note to self: modmore support email 10888/10457/11220]
Alternatively perhaps Babel could fire a plugin event that CRCs can hook into to copy across their own stuff, that could also work.
@Mark-H Babel provides 3 events:
- OnBabelDuplicate: invoked on duplicating the resource in a new language context
- OnBabelLink: invoked on link the resource with a target resource
- OnBabelUnlink: invoked on unlink the resource from a target resource