===== Resources Bundle =====
GroIMP uses a bundle approach to link resources and Registry items.
==== String resources ====
Most resources used in GroIMP defined in property files are String.
The two main examples are:
* Name of registry item, usually the name are defined at the plugin level (in //plugin.properties//). E.g. for the menu item _open_ it is defined like:
>/ui/commands/open.Name = &Open...
* Messages to be displayed in GroIMP. Usually these messages are defined at a package level (in _Resources.properties_). E.g. the message dialog of closing a unsaved project has the following properties:
project.savequestion.title = Save Project
project.savequestion.msg = The project {0} has been modified. Save changes?
The _project.savequestion.msg_ can be accesed with:
public static final I18NBundle I18N = I18NBundle.getInstance (UI.class);
String VAR = "PROJECT NAME";
UI.I18N.msg ("project.savequestion.msg", VAR)
in this example, the _Resources.property_ file is at the root of the UI.class file, thus it can be accessed with _I18NBundle.getInstance (UI.class)_. In your plugin, you can access your _Resources.property_ by using one class of your package as long as both the .class and .property files are on the same level.
The VAR _PROJECT NAME_ is injected in the property message under {0}. The message can include any numer of parameters used like: _I18N.msg (PROPERTY_NAME, VAR1, VAR2, ...)_.
==== Other object resources ====
GroIMP bundle also works with other object resources, such as Icon or Image.
In that case, the definition of the resource change slightly. For instance the registry command that define _undo for text_ has the properties:
text.undo.Name = Undo
text.undo.ShortDescription = Undo
text.undo.Icon = \`icon actions/undo\`
An _Icon_ is defined with _\`icon actions/undo\`_. First the \` symbol at the begining and end of the resource is used to define a non String resource. Then, the property is defined in two part separated by the first space:
- the first part, _icon_ in this example, defines the type of resources.
- the second part, _actions/undo_ defines its value.
GroIMP uses ResourcesConverter objects to load the given resource into the correct java object.
See [[:GroIMP-Platform:Resource-converter|how to create a new Resource converter]].