Alfresco 中以编程方式提供多语言内容

发布于 2025-01-05 18:00:06 字数 1248 浏览 1 评论 0原文

我收到的要求是使用 Alfresco 内容管理对 SQL Server 数据库上可用的一些现有内容进行建模,因此,我创建了新的内容模型,它似乎工作正常。但我在多语言方面遇到了问题:我知道在 Alfresco 中一个节点可以添加多种语言(我如何使用 Java 来实现大量负载?),但是,我还使用了一些需要翻译的方面。

在这种情况下你通常会做什么?我想按照以下步骤操作:

  • 创建 Eng 内容并添加方面
  • 创建新的子翻译并添加方面

这是正确的吗?如何以编程方式创建多语言节点(Java)以及如何添加带有方面的新翻译内容?我查看了 Alfresco 文档,但是没有找到,您能帮我找到一些相关的文档或教程吗?

更新:

我正在尝试制作多语言内容:

void makeTranslation(Reference contentNodeRef, Locale locale) throws AlfrescoRuntimeException, Exception
    {
        try {
            NodeRef nodeRef = new NodeRef("workspace://SpacesStore/" + contentNodeRef.getUuid());           
            MultilingualContentServiceImpl multilingualContentServiceImpl = new MultilingualContentServiceImpl();       

            multilingualContentServiceImpl.makeTranslation(nodeRef, locale);
        }
        catch (org.alfresco.error.AlfrescoRuntimeException ex) {
            throw new AlfrescoRuntimeException(ex.getMessage());
        }
        catch (Exception ex) {
            throw new Exception(ex.getMessage());
        }
    }

但是,makeTranslation 引发 nullPoint 异常,因为 MultilingualContentServiceImpl 未正确初始化。有什么建议如何初始化它吗?我必须使用弹簧,但是如何呢?

任何建议或回复都会非常有帮助!

谢谢,
安德里亚

The requirement I receive is to model some existing content available on a SQL Server database using Alfresco content managment so, I create my new content model and it seems to working fine. But I've a problem with multi language: I know in Alfresco is possible for one node add multiple language (how can I do that using Java for a massive load?) but, I used also some aspects that need to be translated.

What do you usually do in that case? I thoug to follow this steps:

  • Create Eng content and add aspects
  • Create new child translted and add aspects

Is it correct? How can I make a node Multilingual programmatically (Java) and how can I add the new translate content with aspects? I took a look to Alfresco documentation but, I didn't find it, could you help me to find some documentation or tutorial about that?

UPDATE:

I'm trying to make a content multilangue:

void makeTranslation(Reference contentNodeRef, Locale locale) throws AlfrescoRuntimeException, Exception
    {
        try {
            NodeRef nodeRef = new NodeRef("workspace://SpacesStore/" + contentNodeRef.getUuid());           
            MultilingualContentServiceImpl multilingualContentServiceImpl = new MultilingualContentServiceImpl();       

            multilingualContentServiceImpl.makeTranslation(nodeRef, locale);
        }
        catch (org.alfresco.error.AlfrescoRuntimeException ex) {
            throw new AlfrescoRuntimeException(ex.getMessage());
        }
        catch (Exception ex) {
            throw new Exception(ex.getMessage());
        }
    }

but, makeTranslation raise an nullPoint exception because MultilingualContentServiceImpl it's not initialized correctly. Any suggestion how to initialize it? I've to use spring but, how?

Any suggerstion or reply will be very helpful!

Thanks,
Andrea

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷情妓 2025-01-12 18:00:06

您可以使用 MultilingualContentService 添加翻译。但!我想您的属性应该是 d:mltext 类型(如 cm:title 和 cm:description )以支持多语言内容。

这意味着,如果您使用英语浏览器访问 alfresco,您将看到与在浏览器中使用德语设置的人不同的描述。这可能有点令人困惑,因为在 Share 中没有(曾经?)没有标识符表明该属性是多语言的。

如果您希望您的翻译出现在任何地方,无论人们在浏览器中使用哪种语言,那么更好的方法是定义某个方面(例如 ex:translatable),并具有与您需要翻译一样多的属性。然后,您可以以编程方式(使用 Java 或 JavaScript)使用搜索服务来查找所需的节点并向其添加方面。最后,您将该方面的属性(翻译)添加到节点。

我希望这有助于澄清一些事情......:)

You can use MultilingualContentService to add translations. But! I guess your properties should be of type d:mltext (like cm:title and cm:description are) to support multilingual content.

This means if you access alfresco using browser with english language you will see a different description as someone using german language settings in browser. This can be a little confusing because in Share there is (was?) no identifier that the property is multilingual.

If you want your translations to appear everywhere, no matter what kind of language in browser people are using, then the better approach is to define some aspect (for example ex:translatable) with as many properties as you need translations. Then you can programatically (using Java or JavaScript) use search service to find nodes you want and add the aspect to them. Finally you then add properties (translations) of that aspect to the node.

I hope this helps to clear things a bit... :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文