Hi,

 just a quick response ... I have not really tried, but as far as I remember 
something like:

  translatedDoc = newDoc.getTranslatedDocument(language)

should work.

The explanation is that translations of given document are not completely 
different documents (so you do not have to make a copy to create them),
but instead "variants" of the document in the default language, so you can 
access them directly from the document itself

HTH
Clemens


On 12/15/2014 12:01 PM, David Delbecq wrote:
> 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 
> 
> _______________________________________________
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
> 



mit freundlichen Grüßen
Clemens Klein-Robbenhaar

-- 
Clemens Klein-Robbenhaar
Software Development
EsPresto AG
Breite Str. 30-31
10178 Berlin/Germany
Tel: +49.(0)30.90 226.763
Fax: +49.(0)30.90 226.760
robbenh...@espresto.com

HRB 77554 B - Berlin-Charlottenburg
Vorstand: Maya Biersack, Peter Biersack
Vorsitzender des Aufsichtsrats: Dipl.-Wirtsch.-Ing. Winfried Weber
Zertifiziert nach ISO 9001:2008
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to