在Liferay 7中覆盖来自admin-web的翻译

时间:2016-12-16 10:50:38

标签: liferay liferay-7

Thera是com.liferay.plugins.admin.webcom.liferay.portal.instances.web模块中的一些转换,我想覆盖它们。通过其他模块,我成功地完成了本教程: https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/overriding-a-modules-language-keys

在这种情况下,com.liferay.plugins.admin.web模块没有servlet.context.name,这在类属性中是必需的。有没有办法覆盖这个翻译?提前感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

最佳解决方案是创建一个从ResourceBundle扩展的翻译模块:

package com.galian.extranet.resourcebundle;
import com.liferay.portal.kernel.language.UTF8Control;

import java.util.Enumeration;
import java.util.ResourceBundle;

import org.osgi.service.component.annotations.Component;

/**
 * @author
 *
 */
@Component(immediate = true, property = { "language.id=en_US" }, service = ResourceBundle.class)
public class DefaultCustomResourceBundle extends ResourceBundle {

    @Override
    public Enumeration<String> getKeys() {
        return _resourceBundle.getKeys();
    }

    @Override
    protected Object handleGetObject(String key) {
        return _resourceBundle.getObject(key);
    }

    private final ResourceBundle _resourceBundle = ResourceBundle.getBundle("content.Language", UTF8Control.INSTANCE);

}

您的模块项目结构如下:

enter image description here