Index: tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/PluginMessages.java
===================================================================
--- tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/PluginMessages.java	(revision 1265)
+++ tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/i18n/PluginMessages.java	(revision 1266)
@@ -86,6 +86,33 @@
 	TreeSet<String> messageKeys = new TreeSet<String>();
 
 	/**
+	 * plugin.xml file -> contains eventually keys
+	 */
+	protected File pluginXMLFile;
+	
+	public File getPluginXMLFile() {
+		return pluginXMLFile;
+	}
+
+	public TreeSet<String> getOsgiKeys() {
+		return osgiKeys;
+	}
+
+	public TreeMap<File, BiHashMap<String, String>> getOsgiLangs() {
+		return osgiLangs;
+	}
+
+	/**
+	 * the OSGI-INF/l10n/bundle[_lang].properties OSGI message keys
+	 */
+	TreeSet<String> osgiKeys = new TreeSet<String>();
+	
+	/**
+	 * The OSGI messages stored by properties file
+	 */
+	TreeMap<File, BiHashMap<String, String>> osgiLangs = new TreeMap<File, BiHashMap<String, String>>();
+	
+	/**
 	 * Stores the key modifications for further saves in the source files
 	 */
 	HashMap<String, String> keyModifications = new HashMap<String, String>();
@@ -118,6 +145,10 @@
 		if (!messagesPackageDir.exists()) {
 			messagesPackageDir = new File(projectDirectory2, "src/java/"+projectDirectory2.getName().replaceAll("\\.", "/")+"/messages");
 		}
+		
+		if (!messagesPackageDir.exists()) {
+			messagesPackageDir = new File(projectDirectory2, "src/main/java/"+projectDirectory2.getName().replaceAll("\\.", "/")+"/messages");
+		}
 
 		if (!messagesPackageDir.exists()) {
 			return null;
@@ -155,6 +186,7 @@
 
 		this.javaMessageFile = javaMessageFile;
 		this.projectDirectory = projectDirectory;
+		this.pluginXMLFile = new File(projectDirectory, "plugin.xml");
 		this.srcFiles = new ArrayList<File>();
 		this.debug = debug;
 
@@ -201,6 +233,25 @@
 
 		//this.createKeysGlobalREGEX();
 		this.createUsedKeysFilesIndex();
+		
+		// try loading OSGI messages 
+		if (pluginXMLFile.exists()) {
+			ArrayList<String> result = IOUtils.findWithGroup(pluginXMLFile, "\"%([^\"]+)\"");
+			osgiKeys.addAll(result);
+			
+			File osgiInf = new File(projectDirectory, "OSGI-INF/l10n");
+			if (osgiInf.exists()) {
+				for (File propFile : osgiInf.listFiles()) {
+					if (propFile.getName().startsWith("bundle") && propFile.getName().endsWith(".properties")) {
+						Properties props = new Properties();
+						props.load(IOUtils.getReader(propFile));
+						osgiLangs.put(propFile, new BiHashMap<String, String>(props));
+					}
+				}
+			}
+			System.out.println(osgiKeys);
+			System.out.println(osgiLangs);
+		}
 
 		if(debug)	{
 			this.dumpUsedKeysFilesIndex();
@@ -423,7 +474,7 @@
 	static {
 		col.setStrength(Collator.TERTIARY);
 	}
-	public void saveChanges() throws IOException {
+	public void saveChanges(boolean replaceFiles) throws IOException {
 
 		//Write prop File
 		for (File propFile : langs.keySet()) {
@@ -432,8 +483,12 @@
 				@Override
 				public synchronized Enumeration<Object> keys() {
 					TreeSet<Object> set = new TreeSet<Object>(comp);
+					System.out.println(set);
 					set.addAll(super.keySet());
-					return Collections.enumeration(set);
+					System.out.println(set);
+					Enumeration<Object> en = Collections.enumeration(set);
+					System.out.println(set);
+					return en;
 				}
 			};
 			BiHashMap<String, String> h = langs.get(propFile);
@@ -442,6 +497,10 @@
 			}
 
 			File newPropFile = new File(propFile.getParentFile(), propFile.getName()+".new");
+			if (replaceFiles) {
+				propFile.delete();
+				newPropFile = propFile;
+			}
 			props.store(IOUtils.getWriter(newPropFile, ENCODING), "TXM messages generated by the PluginMessages class");
 		}
 
@@ -449,6 +508,10 @@
 		if (javaMessageFile == null) return;
 
 		File newJavaMessageFile = new File(javaMessageFile.getParentFile(), javaMessageFile.getName()+".new");
+		if (replaceFiles) {
+			javaMessageFile.delete();
+			newJavaMessageFile = javaMessageFile;
+		}
 
 		String className = getMessageClassName();
 		String name = getMessageName();
@@ -469,7 +532,9 @@
 		out.println("	private static final String BUNDLE_NAME = \""+classPackage+".messages\"; //$NON-NLS-1$\n");
 
 		//write keys
-		for (String key : this.getMessageKeys()) {
+		ArrayList<String> keys = new ArrayList<String>(this.getMessageKeys());
+		Collections.sort(keys, comp);
+		for (String key : keys) {
 			out.println("	public static String "+key+";");
 		}
 
@@ -686,7 +751,7 @@
 	 */
 	public static void main(String[] args) throws UnsupportedEncodingException, FileNotFoundException, IOException {
 
-		File projectFile = new File(new File(System.getProperty("user.dir")).getParentFile().getAbsolutePath() + "/org.txm.core");
+		File projectFile = new File(new File(System.getProperty("user.dir")).getParentFile().getAbsolutePath() + "/org.txm.rcp");
 
 		PluginMessages pmManager = new PluginMessages(projectFile);
 
@@ -714,7 +779,7 @@
 		//dict.summary();
 
 
-		pmManager.saveChanges();
+		//pmManager.saveChanges(true);
 
 		System.out.println("PluginMessages.main(): done.");
 	}
