package backupBasic.backup;
/*(c)2016, Tobias Hotz
 * Further Information can be found in Info.txt
 */

import java.io.File;
import java.io.IOException;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author Tobias Hotz
 */
public class Main {
	private static final Logger logger = Logger.getLogger(Main.class.getName());
	private static ResourceBundle messages;
	static {
		logger.setLevel(Level.ALL);
	}
	
	/**
	 * Verwaltet das Logging-System
	 */
	private static void initLogging() {
		Handler fileHandler = null;
		try {
			if(System.getProperty("os.name").startsWith("Windows")) {
				//Ordner erstellen
				new File(System.getProperty("user.home") + "/AppData/Local/BackupBasic").mkdirs();
				fileHandler = new FileHandler(System.getProperty("user.home") + "/AppData/Local/BackupBasic/LogBackupBasic.xml");
			}
			else {
				//Ordner erstellen
				new File(System.getProperty("user.home") + "BackupBasic").mkdirs();
				fileHandler = new FileHandler(System.getProperty("user.home")+ "/BackupBasic/LogBackupBasic.xml");
			}
			//Fgt FileHandler global hinzu
		    logger.getParent().addHandler(fileHandler);
		}
		catch (IOException e) {
			logger.severe(messages.getString("LogError"));
			e.printStackTrace();
		}

	    logger.info(messages.getString("LogStart"));
	}
	
	public static ResourceBundle getMessages() {
		return messages;
	}
	
	
	/**
	 * Verwaltet das Logging-System und gibt dann an den ArgParser ab
	 * @param args
	 */
	public static void main(String[] args) {
		Locale currentLocale;
		String userLanguage;
		String userCountry;
		
		userCountry = System.getProperty("user.country");
		userLanguage = System.getProperty("user.language");
		
		currentLocale = new Locale(userLanguage, userCountry);
		try {
			messages = ResourceBundle.getBundle("BackupBasic", currentLocale);
		}
		catch(MissingResourceException e) {
			//TODO Change to English, when Localisation done
			System.out.println("Fallback: German");
			messages = ResourceBundle.getBundle("BackupBasic", new Locale("de", "DE"));
		}
		initLogging();
		ArgParser.parseArgs(args);
	}
}

@@ -2042,60 +2042,8 @@
 ) %7B%0A
-%09%09%09//TODO Change to English, when Localisation done%0A
 %09%09%09S
@@ -2075,14 +2075,15 @@
 ck: 
-German
+English
 %22);%0A
@@ -2152,16 +2152,16 @@
 le(%22
-d
 e
+n
 %22, %22
-DE
+US
 %22));

Change default language to German