How to create a document translation

Hi.
How can I create a translation of a document using a script?
I’m trying with $xwiki.copyDocument() but I still having a problem :frowning: . I am able to add content to a translated document, but the problem comes when there is no translation created yet