I would like to 开发者_开发知识库link one item as the translation of another item, programmatically, in LinguaPlone. What's the API?
You need to make sure you have the canonical object first:
canonical = object.getCanonical()
You can then link your translation by calling addTranslationReference
on the translation:
translatedObject.addTranslationReference(canonical)
That's all. The LinguaPlone API is rather under-documented, your best bet is to look at the I18NBaseObject source code. The most important thing to remember is that there is always one canonical object, with any translations linked to it via references, where the reference points from translations to the canonical object.
I think it's obj.addTranslationReference(tr_obj), the target language is taken from tr_obj. But that's only based on a brief look at I18NBaseObject.py: Plone is my day job and it's weekend. :)
精彩评论