diff --git a/ShiftOS.Objects/UniteClient.cs b/ShiftOS.Objects/UniteClient.cs
index ccd721b..8843930 100644
--- a/ShiftOS.Objects/UniteClient.cs
+++ b/ShiftOS.Objects/UniteClient.cs
@@ -23,7 +23,7 @@ namespace ShiftOS.Unite
{
get
{
- return UserConfig.Get().UniteUrl;
+ return "";
}
}
diff --git a/ShiftOS.Objects/UserConfig.cs b/ShiftOS.Objects/UserConfig.cs
index 61d11b8..579ce00 100644
--- a/ShiftOS.Objects/UserConfig.cs
+++ b/ShiftOS.Objects/UserConfig.cs
@@ -10,7 +10,7 @@ namespace ShiftOS.Objects
{
public class UserConfig
{
- public string UniteUrl { get; set; }
+ public string Language { get; set; }
public string DigitalSocietyAddress { get; set; }
public int DigitalSocietyPort { get; set; }
@@ -18,7 +18,7 @@ namespace ShiftOS.Objects
{
var conf = new UserConfig
{
- UniteUrl = "http://getshiftos.ml",
+ Language = "english",
DigitalSocietyAddress = "michaeltheshifter.me",
DigitalSocietyPort = 13370
};
diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs
index baf5b64..3ea8a28 100644
--- a/ShiftOS.Server/SaveManager.cs
+++ b/ShiftOS.Server/SaveManager.cs
@@ -184,17 +184,6 @@ namespace ShiftOS.Server
}
catch { }
- try
- {
- //Update the shiftos website with the user's codepoints.
- if (!string.IsNullOrWhiteSpace(sav.UniteAuthToken))
- {
- var wreq = WebRequest.Create(UserConfig.Get().UniteUrl + "/API/SetCodepoints/" + sav.Codepoints.ToString());
- wreq.Headers.Add("Authentication: Token " + sav.UniteAuthToken);
- wreq.GetResponse();
- }
- }
- catch { }
}
diff --git a/ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs b/ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs
index a9291d3..9ef91ad 100644
--- a/ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs
+++ b/ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs
@@ -50,6 +50,8 @@
this.lbcurrentui = new System.Windows.Forms.Label();
this.shiftos = new System.Windows.Forms.PictureBox();
this.lbbuilddetails = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.cblanguage = new System.Windows.Forms.ComboBox();
this.flmenu.SuspendLayout();
this.pnloptions.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
@@ -138,6 +140,8 @@
//
// pnloptions
//
+ this.pnloptions.Controls.Add(this.cblanguage);
+ this.pnloptions.Controls.Add(this.label3);
this.pnloptions.Controls.Add(this.txtdsport);
this.pnloptions.Controls.Add(this.label2);
this.pnloptions.Controls.Add(this.txtdsaddress);
@@ -145,7 +149,7 @@
this.pnloptions.Controls.Add(this.flowLayoutPanel1);
this.pnloptions.Location = new System.Drawing.Point(49, 26);
this.pnloptions.Name = "pnloptions";
- this.pnloptions.Size = new System.Drawing.Size(432, 167);
+ this.pnloptions.Size = new System.Drawing.Size(432, 198);
this.pnloptions.TabIndex = 2;
//
// txtdsport
@@ -188,7 +192,7 @@
this.flowLayoutPanel1.Controls.Add(this.btnsave);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
- this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 136);
+ this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 167);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(432, 31);
this.flowLayoutPanel1.TabIndex = 0;
@@ -295,6 +299,23 @@
this.lbbuilddetails.TabIndex = 6;
this.lbbuilddetails.Text = "label4";
//
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(25, 117);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(139, 13);
+ this.label3.TabIndex = 5;
+ this.label3.Text = "{MAINMENU_LANGUAGE}";
+ //
+ // cblanguage
+ //
+ this.cblanguage.FormattingEnabled = true;
+ this.cblanguage.Location = new System.Drawing.Point(146, 117);
+ this.cblanguage.Name = "cblanguage";
+ this.cblanguage.Size = new System.Drawing.Size(225, 21);
+ this.cblanguage.TabIndex = 6;
+ //
// MainMenu
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -348,5 +369,7 @@
private System.Windows.Forms.Label lbcurrentui;
private System.Windows.Forms.PictureBox shiftos;
private System.Windows.Forms.Label lbbuilddetails;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.ComboBox cblanguage;
}
}
\ No newline at end of file
diff --git a/ShiftOS.WinForms/MainMenu/MainMenu.cs b/ShiftOS.WinForms/MainMenu/MainMenu.cs
index f6bc833..b957c28 100644
--- a/ShiftOS.WinForms/MainMenu/MainMenu.cs
+++ b/ShiftOS.WinForms/MainMenu/MainMenu.cs
@@ -156,6 +156,15 @@ namespace ShiftOS.WinForms.MainMenu
txtdsaddress.Text = conf.DigitalSocietyAddress;
txtdsport.Text = conf.DigitalSocietyPort.ToString();
+ cblanguage.Items.Clear();
+ foreach(var lang in Localization.GetAllLanguages())
+ {
+ var finf = new System.IO.FileInfo(lang);
+ int nameindex = finf.Name.Length - 5;
+ cblanguage.Items.Add(finf.Name.Remove(nameindex, 5));
+ }
+
+ cblanguage.Text = conf.Language;
pnloptions.Show();
pnloptions.BringToFront();
@@ -186,9 +195,20 @@ namespace ShiftOS.WinForms.MainMenu
conf.DigitalSocietyPort = p;
+ bool requiresRestart = (conf.Language != cblanguage.Text);
+ conf.Language = cblanguage.Text;
+
+
System.IO.File.WriteAllText("servers.json", Newtonsoft.Json.JsonConvert.SerializeObject(conf, Newtonsoft.Json.Formatting.Indented));
HideOptions();
+ if(requiresRestart == true)
+ {
+ Infobox.Show("{TITLE_RESTARTREQUIRED}", "{PROMPT_RESTARTREQUIRED}", () =>
+ {
+ Application.Restart();
+ });
+ }
}
private void button10_Click(object sender, EventArgs e)
diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs
index f56285a..cd17a31 100644
--- a/ShiftOS.WinForms/Properties/Resources.Designer.cs
+++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs
@@ -1328,6 +1328,23 @@ namespace ShiftOS.WinForms.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to /*
+ /// * French translation
+ /// *
+ /// * Made by Michael VanOverbeek with his grade 9 french skills because why not.
+ /// *
+ /// */
+ ///
+ ///{
+ ///}.
+ ///
+ internal static string strings_fr {
+ get {
+ return ResourceManager.GetString("strings_fr", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx
index 5e5555b..175c52d 100644
--- a/ShiftOS.WinForms/Properties/Resources.resx
+++ b/ShiftOS.WinForms/Properties/Resources.resx
@@ -34615,4 +34615,7 @@
..\Resources\austmicrotrends.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\Resources\strings_fr.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
+
\ No newline at end of file
diff --git a/ShiftOS.WinForms/Resources/strings_en.txt b/ShiftOS.WinForms/Resources/strings_en.txt
index 55402ab..2d13fb6 100644
--- a/ShiftOS.WinForms/Resources/strings_en.txt
+++ b/ShiftOS.WinForms/Resources/strings_en.txt
@@ -140,7 +140,8 @@
"{TITLE_SHIFTSWEEPER}": "ShiftSweeper",
"{TITLE_TERMINAL}": "Terminal",
"{TITLE_TEXTPAD}": "TextPad",
-
+ "{TITLE_RESTARTREQUIRED}": "Restart required.",
+
//App Launcher categories
"{AL_PROGRAMMING}": "Programming",
@@ -160,6 +161,7 @@
"{PROMPT_ENTERSYSNAME}": "Please enter a system name for your computer.",
"{PROMPT_INVALIDNAME}": "The name you entered cannot be blank. Please enter another name.",
"{PROMPT_SMALLSYSNAME}": "Your system name must have at least 5 characters in it.",
+ "{PROMPT_RESTARTREQUIRED}": "For the changes you made to take effect, a restart of ShiftOS is required.",
//Pong
"{PONG_LEVELREACHED}": "You've reached level %level!",
@@ -188,6 +190,7 @@
//Main menu - Settings
"{MAINMENU_DSADDRESS}": "Digital Society address: ",
"{MAINMENU_DSPORT": "Digital Society port: ",
+ "{MAINMENU_LANGUAGE}": "Language:",
//Main Menu - General text
"{MAINMENU_TITLE}": "Main menu",
diff --git a/ShiftOS.WinForms/Resources/strings_fr.txt b/ShiftOS.WinForms/Resources/strings_fr.txt
new file mode 100644
index 0000000..666277a
--- /dev/null
+++ b/ShiftOS.WinForms/Resources/strings_fr.txt
@@ -0,0 +1,9 @@
+/*
+ * French translation
+ *
+ * Made by Michael VanOverbeek with his grade 9 french skills because why not.
+ *
+ */
+
+{
+}
\ No newline at end of file
diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj
index a6d9ff7..8c1accc 100644
--- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj
+++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj
@@ -436,12 +436,6 @@
-
- UserControl
-
-
- UniteLoginDialog.cs
-
UserControl
@@ -642,9 +636,6 @@
Volume.cs
-
- UniteLoginDialog.cs
-
UniteSignupDialog.cs
@@ -873,6 +864,7 @@
+
diff --git a/ShiftOS.WinForms/UniteLoginDialog.Designer.cs b/ShiftOS.WinForms/UniteLoginDialog.Designer.cs
deleted file mode 100644
index f510393..0000000
--- a/ShiftOS.WinForms/UniteLoginDialog.Designer.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-namespace ShiftOS.WinForms
-{
- partial class UniteLoginDialog
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Component Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.txtusername = new System.Windows.Forms.TextBox();
- this.txtpassword = new System.Windows.Forms.TextBox();
- this.btnlogin = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(16, 15);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(84, 13);
- this.label1.TabIndex = 0;
- this.label1.Tag = "header2";
- this.label1.Text = "Login to ShiftOS";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(16, 82);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(35, 13);
- this.label2.TabIndex = 1;
- this.label2.Text = "Email:";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(16, 115);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(56, 13);
- this.label3.TabIndex = 2;
- this.label3.Text = "Password:";
- //
- // txtusername
- //
- this.txtusername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.txtusername.Location = new System.Drawing.Point(112, 79);
- this.txtusername.Name = "txtusername";
- this.txtusername.Size = new System.Drawing.Size(424, 20);
- this.txtusername.TabIndex = 3;
- //
- // txtpassword
- //
- this.txtpassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.txtpassword.Location = new System.Drawing.Point(112, 112);
- this.txtpassword.Name = "txtpassword";
- this.txtpassword.Size = new System.Drawing.Size(424, 20);
- this.txtpassword.TabIndex = 4;
- this.txtpassword.UseSystemPasswordChar = true;
- //
- // btnlogin
- //
- this.btnlogin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.btnlogin.Location = new System.Drawing.Point(460, 148);
- this.btnlogin.Name = "btnlogin";
- this.btnlogin.Size = new System.Drawing.Size(75, 23);
- this.btnlogin.TabIndex = 5;
- this.btnlogin.Text = "Login";
- this.btnlogin.UseVisualStyleBackColor = true;
- this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click);
- //
- // UniteLoginDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.btnlogin);
- this.Controls.Add(this.txtpassword);
- this.Controls.Add(this.txtusername);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.Name = "UniteLoginDialog";
- this.Size = new System.Drawing.Size(573, 192);
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.TextBox txtusername;
- private System.Windows.Forms.TextBox txtpassword;
- private System.Windows.Forms.Button btnlogin;
- }
-}
diff --git a/ShiftOS.WinForms/UniteLoginDialog.cs b/ShiftOS.WinForms/UniteLoginDialog.cs
deleted file mode 100644
index c78e987..0000000
--- a/ShiftOS.WinForms/UniteLoginDialog.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Data;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using ShiftOS.Engine;
-using System.Net;
-using ShiftOS.Objects;
-
-namespace ShiftOS.WinForms
-{
- public partial class UniteLoginDialog : UserControl, IShiftOSWindow
- {
- public UniteLoginDialog(Action callback)
- {
- InitializeComponent();
- Callback = callback;
- }
-
- private Action Callback { get; set; }
-
- public void OnLoad()
- {
- this.ParentForm.AcceptButton = btnlogin;
- }
-
- public void OnSkinLoad()
- {
- }
-
- public bool OnUnload()
- {
- return true;
- }
-
- public void OnUpgrade()
- {
- }
-
- private void btnlogin_Click(object sender, EventArgs e)
- {
- string u = txtusername.Text;
- string p = txtpassword.Text;
-
- if (string.IsNullOrWhiteSpace(u))
- {
- Infobox.Show("Please enter a username.", "You must enter a proper email address.");
- return;
- }
-
- if (string.IsNullOrWhiteSpace(p))
- {
- Infobox.Show("Please enter a password.", "You must enter a valid password.");
- return;
- }
-
- try
- {
- var webrequest = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4");
- string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}"));
- webrequest.Headers.Add("Authentication: Basic " + base64);
- var response = webrequest.GetResponse();
- var str = response.GetResponseStream();
- var reader = new System.IO.StreamReader(str);
- string result = reader.ReadToEnd();
- reader.Close();
- str.Close();
- str.Dispose();
- response.Dispose();
- Callback?.Invoke(result);
- AppearanceManager.Close(this);
- }
-#if DEBUG
- catch(Exception ex)
- {
- Infobox.Show("Error", ex.ToString());
- }
-#else
- catch
- {
- Infobox.Show("Login failed.", "The login attempt failed due to an incorrect username and password pair.");
- }
-#endif
-
- }
- }
-}
diff --git a/ShiftOS.WinForms/UniteLoginDialog.resx b/ShiftOS.WinForms/UniteLoginDialog.resx
deleted file mode 100644
index 1af7de1..0000000
--- a/ShiftOS.WinForms/UniteLoginDialog.resx
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/ShiftOS.WinForms/WFLanguageProvider.cs b/ShiftOS.WinForms/WFLanguageProvider.cs
index 2a431f8..c6a8af0 100644
--- a/ShiftOS.WinForms/WFLanguageProvider.cs
+++ b/ShiftOS.WinForms/WFLanguageProvider.cs
@@ -35,46 +35,86 @@ namespace ShiftOS.WinForms
{
public class WFLanguageProvider : ILanguageProvider
{
+ private string resourcesPath
+ {
+ get
+ {
+ return System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ShiftOS", "languages");
+ }
+ }
+
public string[] GetAllLanguages()
{
- return JsonConvert.DeserializeObject(Properties.Resources.languages);
+ if (!System.IO.Directory.Exists(resourcesPath))
+ {
+ System.IO.Directory.CreateDirectory(resourcesPath);
+ }
+ return System.IO.Directory.GetFiles(resourcesPath).Where(x => x.ToLower().EndsWith(".lang")).ToArray();
+
}
public string GetCurrentTranscript()
{
- try
+ string lang = ShiftOS.Objects.UserConfig.Get().Language;
+ if (string.IsNullOrWhiteSpace(lang))
{
- return getDefault();
+ lang = "english";
+ var conf = Objects.UserConfig.Get();
+ conf.Language = lang;
+ System.IO.File.WriteAllText("servers.json", JsonConvert.SerializeObject(conf, Formatting.Indented));
}
- catch (NullReferenceException)
+ string foundPath = GetAllLanguages().FirstOrDefault(x => x.ToLower().EndsWith(lang + ".lang"));
+ //Update the english file.
+ System.IO.File.WriteAllText(System.IO.Path.Combine(resourcesPath, "english.lang"), Properties.Resources.strings_en);
+ //Update the french language pack.
+ System.IO.File.WriteAllText(System.IO.Path.Combine(resourcesPath, "french.lang"), Properties.Resources.strings_fr);
+
+ if (!System.IO.File.Exists(foundPath))
{
- return getDefault();
+ lang = "english";
+ var conf = Objects.UserConfig.Get();
+ conf.Language = lang;
+ System.IO.File.WriteAllText("servers.json", JsonConvert.SerializeObject(conf, Formatting.Indented));
+ return Properties.Resources.strings_en;
}
+ else
+ {
+ return System.IO.File.ReadAllText(foundPath);
+ }
+
}
public string GetLanguagePath()
{
- switch (SaveSystem.CurrentSave.Language)
+ var lang = Objects.UserConfig.Get().Language;
+ if(string.IsNullOrWhiteSpace(lang) || !System.IO.File.Exists(System.IO.Path.Combine(resourcesPath, lang + ".lang")))
{
- case "deutsch":
- return Paths.GetPath("deutsch.local");
- default:
- return Paths.GetPath("english.local");
-
+ lang = "english";
+ var conf = Objects.UserConfig.Get();
+ conf.Language = lang;
+ System.IO.File.WriteAllText("servers.json", JsonConvert.SerializeObject(conf, Formatting.Indented));
+ System.IO.File.WriteAllText(System.IO.Path.Combine(resourcesPath, lang + ".lang"), Properties.Resources.strings_en);
}
+ return GetAllLanguages().FirstOrDefault(x => x.ToLower().EndsWith(lang + ".lang"));
}
public List GetJSONTranscripts()
{
var strings = new List();
- strings.Add(Properties.Resources.strings_en);
- strings.Add(Properties.Resources.strings_de);
+ foreach (var path in GetAllLanguages())
+ strings.Add(System.IO.File.ReadAllText(path));
return strings;
}
public void WriteDefaultTranscript()
{
- Utils.WriteAllText(Paths.GetPath("english.local"), getDefault());
+ if (!System.IO.Directory.Exists(resourcesPath))
+ System.IO.Directory.CreateDirectory(resourcesPath);
+
+ //Update the english file.
+ System.IO.File.WriteAllText(System.IO.Path.Combine(resourcesPath, "english.lang"), Properties.Resources.strings_en);
+ //Update the french language pack.
+ System.IO.File.WriteAllText(System.IO.Path.Combine(resourcesPath, "french.lang"), Properties.Resources.strings_fr);
}
public void WriteTranscript()