检查Java资源包的工具(i18n)

发布于 2024-09-05 18:31:18 字数 1539 浏览 9 评论 0原文

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

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

发布评论

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

评论(3

水中月 2024-09-12 18:31:18

报告已使用但不在捆绑包中的密钥。报告捆绑包中但不存在映射到该捆绑包的源工件中的键。

你知道,这个非常不典型,我怀疑任何框架都会包含它,因为它需要分析代码并确定哪些调用是对资源包的,哪些可以是作为参数传递的动态字符串等。

通常使用专用编辑器来编辑包, fg ResourceBundle Eclipse 插件,您可以在其中同时编辑原始版本和翻译版本,并且您会看到所有翻译版本中未出现的每个键的警告。

Report used keys which are not in the bundle. Report keys which are in the bundle but in none of the source artifact which map to this bundle.

You know, this one is quite untypical and I doubt any framework would include it, since it requires analysing code and determining, which calls are to resource bundle, which can be dynamic strings passed as arguments etc.

Normally the bundles are edited using dedicated editor, f.g. ResourceBundle plugin for Eclipse, in which you edit original and translation simultanously, and you see warnings for each key not present in all translations.

情独悲 2024-09-12 18:31:18

1) 从 Java 代码、JSP 和其他工件中提取使用的密钥。
由于涉及自定义框架,提取应该允许
定制。

将源工件映射到特定消息包。还带有
自定义规则。

我也遇到了同样的问题并开始开发新的解决方案。我刚刚 发布 今天在我的博客中。它只是使用 Java 注释处理器工具来创建(或更新)属性文件和密钥。正如帖子中所述,它也是可扩展的。它可以在我的 GitHub 项目中找到(您必须从我的博客中找到该链接,因为我不能发布超过 2 个链接)。

请随意使用它并询问您需要的任何内容。


2) 检查每个包的属性文件并报告丢失的密钥
定义和默认翻译(使用英文文本)。

我还发现 此解决方案(尚未尝试过),听起来很有希望!


希望有帮助!

1) Extract the used keys from Java-code, JSPs and other artifacts.
Since custom frameworks are involved the extraction should allow
customization.

Mapping of the source artifact to a certain message bundle. Also with
custom rules.

I've also faced those same issues and started developing a new solution. I just posted it today in my blog. It just uses the Java annotation processor tool to create (or just update) properties files and keys. It is also extensible, as described in the post. And it is available in my GitHub project (you will have to find the link from my blog, as I cannot post more than 2 links).

Feel free to use it and ask whatever you need.


2) Check the property files of each bundle and report missing key
definitions and also default translations (uses the English text).

I have also found this solution (haven't tried it yet), and it sounds promising!


Hope it helps!

屋檐 2024-09-12 18:31:18

为此,我实现了 消息编译器,它创建资源包文件和常量定义为Java enum 用于单个源文件中的键。所以可以在Java源代码中使用常量,这是一种更安全的方式。消息编译器不能仅用于Java。它还为 Objective-C 或 Swift 创建资源文件和常量,并且可以扩展到其他编程环境。

I implemented the Message Compiler for this purpose, which creates the resource bundle files and constant definitions as Java enum for the keys from one single source file. So the constants can be used in the Java source code, which is a much safer way. The message compiler cannot only be used for Java. It creates also resource files and constants for Objective-C or Swift and can be extended for other Programming environments.

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