简体   繁体   English

将I18N接口编译为属性文件

[英]Compiling I18N interface to properties file

I am trying to use the JLibs I18N library. 我正在尝试使用JLibs I18N库。 For the dependencies, I have added the JAR files ( i18n and i18n-apt ) to the Eclipse Build Path: 对于依赖性,我已将JAR文件( i18ni18n-apt )添加到Eclipse Build Path:

Eclipse构建路径

Next, I simply use the sample source code as posted on the website. 接下来,我仅使用网站上发布的示例源代码。

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);
}

So far I get no compiler errors, which is great. 到目前为止,我还没有收到任何编译器错误,这很棒。

Moving on in the tutorial, it says 在本教程中继续说

When you compile this interface with jlibs-core.jar in classpath, it will generate Bundle.properties which contains the messages 当您在类路径中使用jlibs-core.jar编译此接口时,它将生成Bundle.properties,其中包含消息

So I also put jlibs-core into the classpath of Eclipse (see screenshot above) and performed a rebuild. 因此,我还将jlibs-core放入Eclipse的类路径中(请参见上面的屏幕截图)并执行了重建。 Unfortunately, no Bundle.properties file is created, which I checked with Search Everything : every file is from May or older: 不幸的是,没有创建Bundle.properties文件,我通过Search Everything检查了该文件:每个文件都来自May或更旧的版本:

搜索所有内容

What else do I need to make Jlibs compile the I18N interface? 我还需要什么来使Jlibs编译I18N接口?

You might have to enable annotation processing in Eclipse. 您可能必须在Eclipse中启用注释处理。 See instructions here . 请参阅此处的说明

Add jlibs-i18-apt , jlibs-apt and jlibs-core to the factory path and try. jlibs-i18-aptjlibs-aptjlibs-core到工厂路径并尝试。

If you are comfortable with maven you can download a sample maven project . 如果您对Maven感到满意,则可以下载示例Maven项目 When you compile, you can see generated files in target/classes folder. 编译时,您可以在target / classes文件夹中看到生成的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM