Hello,
say i want to create a new Xwikidocument in groovy, and i want this document to already
have two languages. I tried to use this code in groovy and various other variants, but
xwiki keep creating a single version of document, with content in last language of loop
and default language in the default locale of user executing script. It's just
ignoring any tip on local. How can I set translations?
Note: my final purpose is so that a user can upload 2 versions of a odt file in a form,
and i will automatically load it in the concerned translations. Setting translation
content is the last bit i am missing. I can't find any method in xwiki api that says
"here is content translated in language xx" :/
newDoc = xwiki.getDocument(new
DocumentReference("xwiki","Memorandum","Memo-1234","en"));
newDoc.getDocument().setDefaultLanguage(defaultLanguage);
referenceDocument = "Memorandum.Memo-"+number
for (language in ["fr","nl","en"]){
if (title[language] !=null && title[language].trim().length()>0){
println("new document in "+language)
translatedDoc = new Document(
newDoc.getDocument().copyDocument(
new
DocumentReference("xwiki","Memorandum","Memo-1234",language),
xcontext.getContext()),
xcontext.getContext())
translatedDoc.setContent("Hello in "+language+": "+title[language])
translatedDoc.save();
}
}
Any advice would be greatly welcomed
David Delbecq