2012-01-13 91 views

回答

2

將它包裝在可從Web腳本訪問的對象中。 Here's an example它已經做的:

package com.someco.web.jscript; 

import org.alfresco.repo.jscript.ScriptNode; 
import org.alfresco.repo.processor.BaseProcessorExtension; 
import org.alfresco.service.ServiceRegistry; 
import org.alfresco.service.cmr.ml.MultilingualContentService; 
import org.alfresco.service.cmr.repository.NodeRef; 
import org.apache.commons.logging.Log; 
import org.apache.commons.logging.LogFactory; 

import java.util.Locale; 

public final class MultilingualScript extends BaseProcessorExtension 
{ 
    private static final Log logger = LogFactory.getLog(MultilingualScript.class); 

    private MultilingualContentService multilingualContentService; 
    private ServiceRegistry serviceRegistry; 

    public MultilingualScript() 
    { 
     if (logger.isDebugEnabled()) { 
     logger.debug("MultilingualScript Constructor Called"); 
     } 
    } 

    //path = path of the original document 
    //language = required language 
    //returns the noderef for the translation content for the given language 
    public ScriptNode multilingualContent(String path, String language, ScriptNode companyHome) { 
     if (logger.isDebugEnabled()) { 
     logger.debug("MultilingualScript - parameters - " + path + " , " + language); 
     } 
     NodeRef nodeRef = new ScriptNode(companyHome.getNodeRef(), serviceRegistry) 
     .childByNamePath(path).getNodeRef();  
     nodeRef = multilingualContentService.getTranslationForLocale(nodeRef, new Locale(language));  
     return new ScriptNode(nodeRef, serviceRegistry); 
    } 

    public MultilingualContentService getMultilingualContentService() { 
     return multilingualContentService; 
    } 

    public void setMultilingualContentService(
     MultilingualContentService multilingualContentService) { 
     this.multilingualContentService = multilingualContentService; 
    } 

    public ServiceRegistry getServiceRegistry() { 
     return serviceRegistry; 
    } 

    public void setServiceRegistry(ServiceRegistry serviceRegistry) { 
     this.serviceRegistry = serviceRegistry; 
    } 
} 

的春豆:

<bean id="multilingualScript" parent="baseJavaScriptExtension" class="com.someco.web.jscript.MultilingualScript"> 
     <property name="extensionName"> 
      <value>multilingual</value> 
     </property> 
     <property name="serviceRegistry"> 
     <ref bean="ServiceRegistry" /> 
     </property> 
     <property name="multilingualContentService"> 
     <ref bean="MultilingualContentService" /> 
     </property> 
    </bean> 

最後,使用這樣的:

var multilingualArticle = multilingual.multilingualContent("/myarticle", "es", companyhome); 
1

我猜想實際內容不應該很難,因爲每個內容都有他自己的uuid。 難度在於創建UI來上傳不同的語言。

我要做的第一件事就是分析動作'上傳新版本'的工作原理。 所以我們需要的是一個自定義操作來上傳一個不同的語言文件和一個彈出窗口來選擇是哪種語言。所以'上傳新版本'幾乎完全一樣,你可以瀏覽到一個文件並填寫版本評論。

我不知道在資源管理器中是否有可用的webscripts來存儲多語言內容,如果不是,你應該開發這些。

其次是創建一個webscript返回你所有的多語言文件(同上,可能不會存在)

然後定義一個塊,如工作流或版本塊,這樣的鏈接將顯示的文件。