Terry
Terry

Reputation: 14887

Eclipse RCP: what does the percent symbol mean?

I have seen it a couple of times that in the plugin.xml labels or other string values have a leading % symbol. Like in:

<command
    commandId="org.eclipse.ui.examples.contributions.item2"
    icon="icons/editor.gif"
    id="contributions.trimItem"
    label="%Trim.item"
    tooltip="%TrimItem.toolTip">
</command>

in this example.

What does the percent symbol mean? Is it a reference of some kind? If a string value is referenced by it, where is it defined?

Upvotes: 1

Views: 580

Answers (1)

greg-449
greg-449

Reputation: 111218

It means the value for the label or tooltip is actually in a plugin.properties or OSGI-INFO/i10n/bundle.properties file. The value following the % is a property key to look up in that file.

So with '%Trim.item' there will be a line:

Trim.item=the trim label

in the properties file.

This is used to allow the text to be internationalized since Eclipse will look for national language versions of the properties files.

plugin.properties is used if there is a entry Bundle-Localization: plugin in the MANIFEST.MF for the plugin, if there is no Bundle-Localization entry OSGI-INFO/i10n/bundle.properties is used.

If you right click on a plugin.xml (or other files) you can choose 'Plug-in Tools > Externalize Strings...' to start a tool which will convert plugin.xml and MANIFEST.MF strings to this format.

The plugin.xml / MANIFEST.MF editor can generate warnings when you use strings which have not be 'externalized' like this.

Upvotes: 4

Related Questions