Re: [xwiki-users] setting translation from groovy

2014-12-16 Thread David Delbecq
I tried, but the various getTranslated method return exactly the same 
document instance as the one they are called on. Because the document is not 
yet translated. They all seems to work in the model is translation exist, 
return it. Otherwise return the default document, which is not what i am 
looking for.



- Mail original -
De: Clemens Klein-Robbenhaar c.robbenh...@espresto.com
À: users users@xwiki.org
Envoyé: Lundi 15 Décembre 2014 18:54:04
Objet: Re: [xwiki-users] setting translation from groovy

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
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] setting translation from groovy

2014-12-15 Thread David Delbecq
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


Re: [xwiki-users] setting translation from groovy

2014-12-15 Thread Clemens Klein-Robbenhaar
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