mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-22 09:52:15 +00:00
store languages in appdata
This commit is contained in:
parent
49b31c7e84
commit
af9e3401e6
14 changed files with 136 additions and 374 deletions
|
@ -23,7 +23,7 @@ namespace ShiftOS.Unite
|
|||
{
|
||||
get
|
||||
{
|
||||
return UserConfig.Get().UniteUrl;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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 { }
|
||||
|
||||
}
|
||||
|
||||
|
|
27
ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs
generated
27
ShiftOS.WinForms/MainMenu/MainMenu.Designer.cs
generated
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
|
|
17
ShiftOS.WinForms/Properties/Resources.Designer.cs
generated
17
ShiftOS.WinForms/Properties/Resources.Designer.cs
generated
|
@ -1328,6 +1328,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>
|
||||
|
|
|
@ -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>
|
|
@ -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",
|
||||
|
|
9
ShiftOS.WinForms/Resources/strings_fr.txt
Normal file
9
ShiftOS.WinForms/Resources/strings_fr.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* French translation
|
||||
*
|
||||
* Made by Michael VanOverbeek with his grade 9 french skills because why not.
|
||||
*
|
||||
*/
|
||||
|
||||
{
|
||||
}
|
|
@ -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" />
|
||||
|
|
123
ShiftOS.WinForms/UniteLoginDialog.Designer.cs
generated
123
ShiftOS.WinForms/UniteLoginDialog.Designer.cs
generated
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -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))
|
||||
{
|
||||
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<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()
|
||||
|
|
Loading…
Reference in a new issue