cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement makeTranslation?

hbf
Champ on-the-rise
Champ on-the-rise
Hi,

I need to make my nodes multilingual from a script and therefore need a way to emulate from script what a user can do by clicking the "Make multilingual" property in the Web Client.

I first thought that it suffices to add the aspect "cm:mlDocument", but this results in an exception. Digging a little deeper I found in projects/web-client/source/java/org/alfresco/web/bean/ml/MakeMultilingualDialog.java that I am supposed to make a call to the Multilingual Content Service:
multilingualContentService.makeTranslation(nodeRef, locale);
.

Unfortunately, there is no API call (neither in the PHP API – what I am using right now – nor in the JavaScript API) that does this. So I thought I would implement it myself in Alfresco PHP's Node.php.

Alfresco PHP collects, as far as I understand it, the commands you ask it to do in form of CML statements and executes them at save()-time using update(). It seems that CML does not yet support the Multilingual Content Service.

So I guess one would have to start by adding makeTranslation() in some form to CML, right?

Are there any plans for this? Is there a way around this issue (except, programming in Java instead of PHP)?

Thanks,
Kaspar

P.S. Out of curiosity: why did you choose to "buffer" all commands in Alfresco PHP and execute them all at once in the end? Couldn't you have used the Alfresco transaction support directly and forward all calls immediately to the repository?
4 REPLIES 4

hbf
Champ on-the-rise
Champ on-the-rise
Thinking about it a little more, wouldn't it be more elegant to have
addAspect('cm:mlDocment', options)
trigger a function makeTranslation() which would then do the remaining tasks?

(I do not know the Alfresco source code good enough – it might be that the above simply doesn't work. But it would be in accordance with many features of Alfresco: "just add an aspect"…)

hbf
Champ on-the-rise
Champ on-the-rise
Hm, quite some time has passed. So let me ask differently, maybe an Alfresco engineer or insider can answer this:

Is adding the 'cm:mlDocument' aspect the way to go if I want to add translations to a node? (Or is this aspect not supported anymore/superceded by another mechanism?)

If yes then it just means that this issue is a bug/missing implementation and will be fixed at some point in the future, right?

Of course, I'd be relieved to hear a 'yes (no), yes' answer 😉 !

kevinr
Star Contributor
Star Contributor
You are correct in that there is no ML support in the JavaScript (or other script based) APIs in Alfresco yet. The only realistic route is the Java API because as you spotted you need to call multilingualContentService.makeTranslation() - there is no way around this as this method performs work not possible in the JavaScript API otherwise.

A way to make it possible to call from scripts, is to write your Java code and make it into a repository Action class. You can call Action classes from the JavaScript API! This means you would only write the Java code once and make it reusable by all scripts.

Thanks,

Kevin

ostein
Champ in-the-making
Champ in-the-making
almost a year has passed, is it still true that the mlDocument aspect cannot be set from a script?