Update build.

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@9192 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2007-09-21 21:03:51 +00:00
committed by derek
parent 705b8dcfb1
commit b849d45abf

View File

@ -12,19 +12,23 @@ import org.jivesoftware.resource.Res;
import org.jivesoftware.spark.SparkManager; import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.plugin.Plugin; import org.jivesoftware.spark.plugin.Plugin;
import org.jivesoftware.spark.util.URLFileSystem; import org.jivesoftware.spark.util.URLFileSystem;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences; import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager; import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import java.awt.event.ActionEvent;
import java.io.File;
import java.net.URL;
import java.util.Locale;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.JMenu; import javax.swing.JMenu;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import java.awt.event.ActionEvent;
import java.net.URL;
import java.util.Enumeration;
import java.util.Locale;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.zip.ZipFile;
/** /**
* Allows for changing of default languages within Spark. * Allows for changing of default languages within Spark.
* *
@ -44,20 +48,18 @@ public class LanguagePlugin implements Plugin {
locales = Locale.getAvailableLocales(); locales = Locale.getAvailableLocales();
// Load files // Load files
URL url = getClass().getClassLoader().getResource("i18n"); URL sparkJar = getClass().getClassLoader().getResource("spark.jar");
File[] files = URLFileSystem.url2File(url).listFiles(); try {
if(files == null){ ZipFile zipFile = new JarFile(URLFileSystem.url2File(sparkJar));
return; for (Enumeration e = zipFile.entries(); e.hasMoreElements();) {
} JarEntry entry = (JarEntry)e.nextElement();
String propertiesName = entry.getName();
for (int i = 0; i < files.length; i++) { // Ignore any manifest.mf entries.
File propertiesFile = files[i];
String propertiesName = propertiesFile.getName();
if (propertiesName.endsWith(".properties")) { if (propertiesName.endsWith(".properties")) {
int lastIndex = propertiesName.lastIndexOf("i18n_"); int lastIndex = propertiesName.lastIndexOf("i18n_");
int period = propertiesName.lastIndexOf("."); int period = propertiesName.lastIndexOf(".");
if (lastIndex == -1) { if (lastIndex == -1 && propertiesName.contains("spark_i18n")) {
addLanguage("en"); addLanguage("en");
} }
else { else {
@ -66,6 +68,12 @@ public class LanguagePlugin implements Plugin {
} }
} }
} }
zipFile.close();
zipFile = null;
}
catch (Throwable e) {
Log.error("Error unzipping plugin", e);
}
actionsMenu.add(languageMenu); actionsMenu.add(languageMenu);
} }