Commit 900b1fb6 authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Added the ability to use i18n with plugins. Please refer to the...

Added the ability to use i18n with plugins. Please refer to the plugin-dev-guide.html for the how-tos.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3861 b35dd754-fafc-0310-a699-88a17e54d16e
parent a7e65a2f
......@@ -37,6 +37,7 @@ plugin directory are as follows:
|- icon_large.gif <- Optional large (32x32) icon associated with the plugin (can also be a .png file)
|- classes/ <- Resources your plugin needs (i.e., a properties file)
|- database/ <- Optional database schema files that your plugin needs
|- i18n/ <- Optional i18n files to allow for internationalization of plugins.
|- lib/ <- Libraries (JAR files) your plugin needs
|- web <- Resources for Admin Console integration, if any
|- WEB-INF/
......@@ -281,6 +282,16 @@ The following HTML snippet demonstrates a valid page:
</pre>
</fieldset>
<h4>Using i18n in your Admin Console Pages</h4>
<p>
To use i18n in your own plugin, you must do the following:
<ul>
<li>Add i18n directory to root directory of your plugin.</li>
<li>Add each resource file using the %name_of_plugin%_i18n "_" language ".properties" naming convention.</li>
<li>To use directly within your jsp, use the LocaleUtils class, and pass in the name of the plugin.<br/><b>Example:&nbsp;</b>&lt;%= LocaleUtils.getLocalizedString("my.title", "myplugin") %&gt;
</li>
</ul>
</p>
<h2>Using the Wildfire Build Script</h2>
<p>
......
......@@ -34,7 +34,7 @@ import java.util.List;
*
* @author Derek DeMoro
*/
class PluginClassLoader {
public class PluginClassLoader {
private URLClassLoader classLoader;
private final List<URL> list = new ArrayList<URL>();
......@@ -58,10 +58,19 @@ class PluginClassLoader {
*/
public void addDirectory(File directory, boolean developmentMode) {
try {
// Add classes directory to classpath.
File classesDir = new File(directory, "classes");
if (classesDir.exists()) {
list.add(classesDir.toURL());
}
// Add i18n directory to classpath.
File i18nDir = new File(directory, "i18n");
if(i18nDir.exists()){
list.add(i18nDir.toURL());
}
// Add lib directory to classpath.
File libDir = new File(directory, "lib");
File[] jars = libDir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
......@@ -161,4 +170,12 @@ class PluginClassLoader {
}
return parent;
}
/**
* Returns the URLClassloader used.
* @return the URLClassLoader used.
*/
public ClassLoader getClassLoader(){
return classLoader;
}
}
......@@ -167,16 +167,14 @@
}
else {
errorBuf.append("<br>").append(
LocaleUtils.getLocalizedString("group.edit.already_user",
JiveGlobals.getLocale(), Arrays.asList(username)));
LocaleUtils.getLocalizedString("group.edit.already_user", Arrays.asList(username)));
}
}
catch (Exception e) {
Log.debug("Problem adding new user to existing group", e);
errorBuf.append("<br>").append(
LocaleUtils.getLocalizedString("group.edit.inexistent_user",
JiveGlobals.getLocale(), Arrays.asList(username)));
LocaleUtils.getLocalizedString("group.edit.inexistent_user", Arrays.asList(username)));
}
}
if (count > 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment