diff --git a/Aura Operating System/Aura OS/Kernel.cs b/Aura Operating System/Aura OS/Kernel.cs
index 611448a69..982c95f6d 100644
--- a/Aura Operating System/Aura OS/Kernel.cs
+++ b/Aura Operating System/Aura OS/Kernel.cs
@@ -10,7 +10,7 @@
using System;
using Cosmos.System.FileSystem;
using Sys = Cosmos.System;
-using Lang = Aura_OS.System.Translation;
+using Aura_OS.System.Translation;
using Aura_OS.System;
using Aura_OS.System.Users;
using Aura_OS.System.Computer;
@@ -44,6 +44,7 @@ public class Kernel : Sys.Kernel
public static bool Logged = false;
public static string ComputerName = "aura-pc";
public static string UserDir = @"0:\Users\" + userLogged + "\\";
+ public static string SystemDir = @"0:\System\";
public static bool SystemExists = false;
public static bool JustInstalled = false;
public static CosmosVFS vFS = new CosmosVFS();
@@ -55,7 +56,8 @@ public class Kernel : Sys.Kernel
public static Config LocalNetworkConfig;
public static Debugger debugger;
public static string current_volume = @"0:\";
-
+ public static LangManager Lang = new LangManager();
+
#endregion
#region Before Run
@@ -74,8 +76,11 @@ protected override void BeforeRun()
{
try
{
+ // initialize languages we support
+ addLanguages();
+
CommandManager.RegisterAllCommands();
-
+
//AConsole = new System.Shell.VGA.VGAConsole(null);
Encoding.RegisterProvider(CosmosEncodingProvider.Instance);
@@ -114,12 +119,12 @@ protected override void BeforeRun()
if (!JustInstalled)
{
- Settings config = new Settings(@"0:\System\settings.conf");
+ Settings config = new Settings("settings.conf");
langSelected = config.GetValue("language");
#region Language
-
- Lang.Keyboard.Init();
+
+ Keyboard.Init();
#endregion
@@ -145,6 +150,17 @@ protected override void BeforeRun()
Crash.StopKernel(ex);
}
}
+
+ ///
+ /// Adds all the languages that we support
+ ///
+ protected void addLanguages()
+ {
+ Lang.addLang("en_US", new Lang("en_US"));
+ Lang.addLang("fr_FR", new Lang("fr_FR"));
+ Lang.addLang("nl_NL", new Lang("nl_NL"));
+ Lang.addLang("it_IT", new Lang("it_IT")):
+ }
#endregion
diff --git a/Aura Operating System/Aura OS/System/Translation/Lang.cs b/Aura Operating System/Aura OS/System/Translation/Lang.cs
new file mode 100644
index 000000000..985936c32
--- /dev/null
+++ b/Aura Operating System/Aura OS/System/Translation/Lang.cs
@@ -0,0 +1,47 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.IO;
+
+namespace Aura_OS.System.Translation
+{
+ public class Lang
+ {
+ public Dictionary lines = new Dictionary();
+
+ private string name;
+ private string path;
+
+ public Lang(string name)
+ {
+ this.name = name;
+ path = @"0:\System\langs\" + name + ".conf";
+
+ if (Kernel.SystemExists)
+ {
+ if (File.Exists(path))
+ {
+ Load();
+ }
+ }
+ }
+
+ public void Load()
+ {
+ lines = File.ReadLines(this.path).Where(IsConfigurationLine).Select(line => line.Split('=')).ToDictionary(line => line[0], line => line[1]);
+ }
+
+ private static bool IsConfigurationLine(string line)
+ {
+ return !line.StartsWith("#") && line.Contains("=");
+ }
+
+ public string Get(string line)
+ {
+ string value;
+ if (lines.TryGetValue(line, out value)) {
+ return value;
+ } else {
+ return null;
+ }
+ }
+ }
diff --git a/Aura Operating System/Aura OS/System/Translation/LangManager.cs b/Aura Operating System/Aura OS/System/Translation/LangManager.cs
new file mode 100644
index 000000000..21f7da188
--- /dev/null
+++ b/Aura Operating System/Aura OS/System/Translation/LangManager.cs
@@ -0,0 +1,37 @@
+using System.Collections.Generic;
+
+namespace Aura_OS.System.Translation
+{
+ public class LangManager
+ {
+ private Dictionary Languages = new Dictionary();
+
+ private string DefaultLang = "en_US";
+
+ public void addLang(string name, Lang lang)
+ {
+ if (!Languages.ContainsKey(name))
+ {
+ Languages.Add(name, lang);
+ }
+ }
+
+ public Lang GetLang(string name)
+ {
+ Lang value;
+ if (Languages.TryGetValue(name, out value))
+ {
+ return value;
+ }
+ else
+ {
+ return Languages[DefaultLang];
+ }
+ }
+
+ public Dictionary getLangs()
+ {
+ return Languages;
+ }
+ }
+}
diff --git a/Aura Operating System/Aura OS/System/Utils/ConfSettings.cs b/Aura Operating System/Aura OS/System/Utils/ConfSettings.cs
new file mode 100644
index 000000000..86b3c2690
--- /dev/null
+++ b/Aura Operating System/Aura OS/System/Utils/ConfSettings.cs
@@ -0,0 +1,131 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.IO;
+
+namespace Aura_OS.System.Utils
+{
+ public class ConfSettings : ISettings
+ {
+
+ private Dictionary config = new Dictionary();
+ private string path;
+
+ public void Load(string path)
+ {
+ this.path = path;
+
+ if (Kernel.SystemExists)
+ {
+ if (File.Exists(path))
+ {
+ config = File.ReadLines(path).Where(IsConfigurationLine).Select(line => line.Split('=')).ToDictionary(line => line[0], line => line[1]);
+ }
+ }
+ }
+
+ private static bool IsConfigurationLine(string line)
+ {
+ return !line.StartsWith("#") && line.Contains("=");
+ }
+
+ public void Save()
+ {
+ if (Kernel.SystemExists)
+ {
+ string[] fileContent = File.ReadAllLines(path);
+ List tempConfig = new List();
+
+ int counter = -1;
+ int index = 0;
+ bool exists = false;
+
+ foreach (string line in fileContent)
+ {
+ tempConfig.Add(line);
+ }
+
+ // loop throuh dictonary
+ foreach (var setting in config)
+ {
+ // see if the current setting exists in the config file
+ foreach(string element in tempConfig)
+ {
+ counter = counter + 1;
+ if (element.Contains(setting.Key))
+ {
+ index = counter;
+ exists = true;
+ }
+ }
+
+ if (exists)
+ {
+ // update the value
+ tempConfig[index] = setting.Key + "=" + setting.Value;
+ }
+ else
+ {
+ // add to temp config
+ tempConfig.Add(setting.Key + "=" + setting.Value);
+ }
+ }
+
+ // now update file content and save
+ fileContent = tempConfig.ToArray();
+ File.WriteAllLines(path, fileContent);
+ }
+ }
+
+ public string GetString(string key)
+ {
+ string value;
+ if (config.TryGetValue(key, out value))
+ {
+ return value;
+ }
+
+ return null;
+ }
+
+ public void SetString(string key, string value)
+ {
+ config[key] = value;
+ }
+
+ public bool? GetBool(string key)
+ {
+ return GetString(key) != null ? bool.Parse(GetString(key)) : new bool?();
+ }
+
+ public void SetBool(string key, bool value)
+ {
+ config[key] = value.ToString();
+ }
+
+ public int? GetInt(string key)
+ {
+ return GetString(key) != null ? int.Parse(GetString(key)) : new int?();
+ }
+
+ public void SetInt(string key, int value)
+ {
+ config[key] = value.ToString();
+ }
+
+ public long? GetLong(string key)
+ {
+ return GetString(key) != null ? long.Parse(GetString(key)) : new long?();
+ }
+
+ public void SetLong(string key, long value)
+ {
+ config[key] = value.ToString();
+ }
+
+ public IDictionary getConfig()
+ {
+ return config;
+ }
+
+ }
+}
diff --git a/Aura Operating System/Aura OS/System/Utils/ISettings.cs b/Aura Operating System/Aura OS/System/Utils/ISettings.cs
new file mode 100644
index 000000000..ac8f63474
--- /dev/null
+++ b/Aura Operating System/Aura OS/System/Utils/ISettings.cs
@@ -0,0 +1,29 @@
+using System.Collections.Generic;
+
+namespace Aura_OS.System.Utils
+{
+ public interface ISettings
+ {
+ void Load(string path);
+
+ void Save();
+
+ string GetString(string key);
+
+ void SetString(string key, string value);
+
+ bool? GetBool(string key);
+
+ void SetBool(string key, bool value);
+
+ int? GetInt(string key);
+
+ void SetInt(string key, int value);
+
+ long? GetLong(string key);
+
+ void SetLong(string key, long value);
+
+ IDictionary getConfig();
+ }
+}
diff --git a/Aura Operating System/Aura OS/System/Utils/JsonSettings.cs b/Aura Operating System/Aura OS/System/Utils/JsonSettings.cs
new file mode 100644
index 000000000..d471b990b
--- /dev/null
+++ b/Aura Operating System/Aura OS/System/Utils/JsonSettings.cs
@@ -0,0 +1,86 @@
+using System.Collections.Generic;
+using System.IO;
+using Newtonsoft.Json;
+
+namespace Aura_OS.System.Utils
+{
+ public class JsonSettings : ISettings
+ {
+ private Dictionary config = new Dictionary();
+ private string path;
+
+ public void Load(string path)
+ {
+ this.path = path;
+
+ if (Kernel.SystemExists)
+ {
+ if (File.Exists(path))
+ {
+ var fileContents = File.ReadAllText(path);
+ config = JsonConvert.DeserializeObject>(fileContents);
+ }
+ }
+ }
+
+ public void Save()
+ {
+ if (Kernel.SystemExists)
+ {
+ string json = JsonConvert.SerializeObject(config, Formatting.Indented);
+ File.WriteAllText(path, json);
+ }
+ }
+
+ public string GetString(string key)
+ {
+ string value;
+ if (config.TryGetValue(key, out value))
+ {
+ return value;
+ }
+
+ return null;
+ }
+
+ public void SetString(string key, string value)
+ {
+ config[key] = value;
+ }
+
+ public bool? GetBool(string key)
+ {
+ return GetString(key) != null ? bool.Parse(GetString(key)) : new bool?();
+ }
+
+ public void SetBool(string key, bool value)
+ {
+ config[key] = value.ToString();
+ }
+
+ public int? GetInt(string key)
+ {
+ return GetString(key) != null ? int.Parse(GetString(key)) : new int?();
+ }
+
+ public void SetInt(string key, int value)
+ {
+ config[key] = value.ToString();
+ }
+
+ public long? GetLong(string key)
+ {
+ return GetString(key) != null ? long.Parse(GetString(key)) : new long?();
+ }
+
+ public void SetLong(string key, long value)
+ {
+ config[key] = value.ToString();
+ }
+
+ public IDictionary getConfig()
+ {
+ return config;
+ }
+ }
+}
diff --git a/Aura Operating System/Aura OS/System/Utils/XmlSettings.cs b/Aura Operating System/Aura OS/System/Utils/XmlSettings.cs
new file mode 100644
index 000000000..355cf074a
--- /dev/null
+++ b/Aura Operating System/Aura OS/System/Utils/XmlSettings.cs
@@ -0,0 +1,99 @@
+using System.Collections.Generic;
+using System.Xml.Linq;
+using System.Linq;
+using System.IO;
+
+namespace Aura_OS.System.Utils
+{
+ class XmlSettings : ISettings
+ {
+ private Dictionary config = new Dictionary();
+ private string path;
+
+ public void Load(string path)
+ {
+ this.path = path;
+
+ if (Kernel.SystemExists)
+ {
+ if (File.Exists(path))
+ {
+ XDocument doc = XDocument.Load(path);
+
+ foreach (XElement element in doc.Descendants().Where(p => p.HasElements == false))
+ {
+ int keyInt = 0;
+ string keyName = element.Name.LocalName;
+
+ while (config.ContainsKey(keyName))
+ {
+ keyName = element.Name.LocalName + "_" + keyInt++;
+ }
+
+ config[keyName] = element.Value;
+ }
+ }
+ }
+ }
+
+ public void Save()
+ {
+ if (Kernel.SystemExists)
+ {
+ XElement settings = new XElement("settings", config.Select(setting => new XElement(setting.Key, setting.Value)));
+ settings.Save(path);
+ }
+ }
+
+ public string GetString(string key)
+ {
+ string value;
+ if (config.TryGetValue(key, out value))
+ {
+ return value;
+ }
+
+ return null;
+ }
+
+ public void SetString(string key, string value)
+ {
+ config[key] = value;
+ }
+
+ public bool? GetBool(string key)
+ {
+ return GetString(key) != null ? bool.Parse(GetString(key)) : new bool?();
+ }
+
+ public void SetBool(string key, bool value)
+ {
+ config[key] = value.ToString();
+ }
+
+ public int? GetInt(string key)
+ {
+ return GetString(key) != null ? int.Parse(GetString(key)) : new int?();
+ }
+
+ public void SetInt(string key, int value)
+ {
+ config[key] = value.ToString();
+ }
+
+ public long? GetLong(string key)
+ {
+ return GetString(key) != null ? long.Parse(GetString(key)) : new long?();
+ }
+
+ public void SetLong(string key, long value)
+ {
+ config[key] = value.ToString();
+ }
+
+ public IDictionary getConfig()
+ {
+ return config;
+ }
+ }
+}