将 I18N 接口编译到属性文件

Compiling I18N interface to properties file

我正在尝试使用 JLibs I18N 库。对于依赖项,我已将 JAR 文件(i18ni18n-apt)添加到 Eclipse 构建路径:

接下来,我简单地使用网站上发布的示例源代码。

import jlibs.core.util.i18n.I18N;
import jlibs.core.util.i18n.Message;
import jlibs.core.util.i18n.ResourceBundle;

@ResourceBundle
public interface DBBundle{
    public static final DBBundle DB_BUNDLE = I18N.getImplementation(DBBundle.class);

    @Message("SQL Execution completed in {0} seconds with {1} errors")
    public String executionFinished(long seconds, int errorCount);

    @Message(key="SQLExecutionException", value="Encountered an exception while executing the following statement:\n{0}")
    public String executionException(String query);

    @Message("executing {0}")
    public String executing(String query);
}

到目前为止我没有遇到任何编译器错误,这很好。

教程继续,它说

When you compile this interface with jlibs-core.jar in classpath, it will generate Bundle.properties which contains the messages

所以我也将 jlibs-core 放入 Eclipse 的类路径中(见上面的屏幕截图)并执行了重建。不幸的是,没有创建 Bundle.properties 文件,我用 Search Everything 进行了检查:每个文件都来自 5 月或更早:

让Jlibs编译I18N接口还需要什么?

您可能必须在 Eclipse 中启用注释处理。参见 instructions here

jlibs-i18-aptjlibs-aptjlibs-core添加到工厂路径并尝试。

如果您熟悉 maven,可以下载 sample maven project。编译时,可以在target/classes文件夹中看到生成的文件。