aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-06-19 10:18:55 -0400
committerMichael <[email protected]>2017-06-19 10:19:03 -0400
commitaf9e3401e6b2c111da172da1671090f6cb33137f (patch)
tree9c6c297455de94764fd6b074311a43564a0c1860
parent49b31c7e847cc7aa9365880f9f92e0498f1450bd (diff)
downloadshiftos_thereturn-af9e3401e6b2c111da172da1671090f6cb33137f.tar.gz
shiftos_thereturn-af9e3401e6b2c111da172da1671090f6cb33137f.tar.bz2
shiftos_thereturn-af9e3401e6b2c111da172da1671090f6cb33137f.zip
store languages in appdata
-rw-r--r--ShiftOS.Objects/UniteClient.cs2
-rw-r--r--ShiftOS.Objects/UserConfig.cs4
-rw-r--r--ShiftOS.Server/SaveManager.cs11
-rw-r--r--ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs27
-rw-r--r--ShiftOS.WinForms/MainMenu/MainMenu.cs20
-rw-r--r--ShiftOS.WinForms/Properties/Resources.Designer.cs17
-rw-r--r--ShiftOS.WinForms/Properties/Resources.resx3
-rw-r--r--ShiftOS.WinForms/Resources/strings_en.txt5
-rw-r--r--ShiftOS.WinForms/Resources/strings_fr.txt9
-rw-r--r--ShiftOS.WinForms/ShiftOS.WinForms.csproj10
-rw-r--r--ShiftOS.WinForms/UniteLoginDialog.Designer.cs123
-rw-r--r--ShiftOS.WinForms/UniteLoginDialog.cs91
-rw-r--r--ShiftOS.WinForms/UniteLoginDialog.resx120
-rw-r--r--ShiftOS.WinForms/WFLanguageProvider.cs68
14 files changed, 136 insertions, 374 deletions
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
@@ -1329,6 +1329,23 @@ namespace ShiftOS.WinForms.Properties {
}
/// <summary>
+ /// Looks up a localized string similar to /*
+ /// * French translation
+ /// *
+ /// * Made by Michael VanOverbeek with his grade 9 french skills because why not.
+ /// *
+ /// */
+ ///
+ ///{
+ ///}.
+ /// </summary>
+ internal static string strings_fr {
+ get {
+ return ResourceManager.GetString("strings_fr", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap SuperDesk_screenshot {
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 @@
<data name="austmicrotrends" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\austmicrotrends.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
+ <data name="strings_fr" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>..\Resources\strings_fr.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
+ </data>
</root> \ 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 @@
<Compile Include="Tools\DitheringEngine.cs" />
<Compile Include="Tools\ShiftOSMenuRenderer.cs" />
<Compile Include="TrailerCommands.cs" />
- <Compile Include="UniteLoginDialog.cs">
- <SubType>UserControl</SubType>
- </Compile>
- <Compile Include="UniteLoginDialog.Designer.cs">
- <DependentUpon>UniteLoginDialog.cs</DependentUpon>
- </Compile>
<Compile Include="UniteSignupDialog.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -642,9 +636,6 @@
<EmbeddedResource Include="StatusIcons\Volume.resx">
<DependentUpon>Volume.cs</DependentUpon>
</EmbeddedResource>
- <EmbeddedResource Include="UniteLoginDialog.resx">
- <DependentUpon>UniteLoginDialog.cs</DependentUpon>
- </EmbeddedResource>
<EmbeddedResource Include="UniteSignupDialog.resx">
<DependentUpon>UniteSignupDialog.cs</DependentUpon>
</EmbeddedResource>
@@ -873,6 +864,7 @@
<None Include="Resources\ShiftOSFull.png" />
<Content Include="Resources\GuessTheNumber.py" />
<None Include="Resources\mindblow.png" />
+ <None Include="Resources\strings_fr.txt" />
<Content Include="SystemIcons\iconArtpad.png" />
<Content Include="SystemIcons\iconAudioPlayer.png" />
<Content Include="SystemIcons\iconBitnoteDigger.png" />
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
- {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Component Designer generated code
-
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- 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<string> callback)
- {
- InitializeComponent();
- Callback = callback;
- }
-
- private Action<string> 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 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
- <!--
- Microsoft ResX Schema
-
- Version 2.0
-
- The primary goals of this format is to allow a simple XML format
- that is mostly human readable. The generation and parsing of the
- various data types are done through the TypeConverter classes
- associated with the data types.
-
- Example:
-
- ... ado.net/XML headers & schema ...
- <resheader name="resmimetype">text/microsoft-resx</resheader>
- <resheader name="version">2.0</resheader>
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>[base64 mime encoded serialized .NET Framework object]</value>
- </data>
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
- <comment>This is a comment</comment>
- </data>
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" use="required" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
-</root> \ 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<string[]>(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))
+ {
+ 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 getDefault();
+ 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<string> GetJSONTranscripts()
{
var strings = new List<string>();
- 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()