在 Eclipse 插件的 plugin.xml 中外部化字符串

2022-01-16 00:00:00 eclipse-plugin eclipse

如何在我的 Eclipse 插件的 plugin.xml 中外部化字符串?

How do I externalize strings in my Eclipse plugin's plugin.xml?

右键单击插件项目 > PDE 工具 > 外部化字符串不会显示我的插件.

Right-clicking on the plugin project > PDE Tools > Externalize Strings does not show up my plugin.

我现在正在尝试手动执行此操作.我在 plugin.properties 中添加了条目,并将 plugin.xml 中的等效字符串替换为 % 符号,后跟字符串键.但这似乎不起作用.我在这里错过了什么?

I'm trying to do this manually now. I added entries in plugin.properties and replaced the equivalent string in plugin.xml with a % sign followed by the string key. But that does not seem to work. What am I missing here?

推荐答案

我终于想通了如何手动外部化插件.

I finally figured out how to manually externalize the plugin.

事实证明,Eclipse 以这种方式将 plugin.xml 外部化:

Eclipse, it turns out, externalizes plugin.xml this way:

  • 在插件清单 (META-INF/MANIFEST.MF) 中,添加以下行

  • In the plugin manifest (META-INF/MANIFEST.MF), add the following line

Bundle-Localization: plugin

您打算将外部化字符串存储在名为plugin.properties"的文件中(原来这是缺少的部分).

where you intend to store the externalized strings in a file called "plugin.properties" (Turns out this was the missing piece).

在plugin.properties中添加外部化字符串键值对.

Add the externalized string key-value pairs in plugin.properties.

将 plugin.xml 中的实际字符串替换为 plugin.properties 中的键(以 % 为前缀).

Replace the actual strings in plugin.xml with the keys from plugin.properties (prefixed with %).

相关文章