Continue translation

This commit is contained in:
wimh 2011-12-28 01:02:30 +01:00
parent f37259c09f
commit 867098d483
10 changed files with 109 additions and 52 deletions

View file

@ -24,12 +24,18 @@ namespace SparkleShare {
public event ShowBubbleEventHandler ShowBubbleEvent;
public delegate void ShowBubbleEventHandler (string title, string subtext, string image_path);
// Short alias for the translations
public static string _ (string s)
{
string t=Program._ (s);
return t;
}
public SparkleBubblesController ()
{
Program.Controller.ConflictNotificationRaised += delegate {
ShowBubble ("Ouch! Mid-air collision!",
"Don't worry, SparkleShare made a copy of each conflicting file.",
ShowBubble (_("Ouch! Mid-air collision!"),
_("Don't worry, SparkleShare made a copy of each conflicting file."),
null);
};

View file

@ -89,11 +89,7 @@ namespace SparkleShare {
// Short alias for the translations
public static string _ (string s)
{
#if __MonoCS__
return Catalog.GetString (s);
#else
return s;
#endif
return Program._ (s);
}
@ -359,6 +355,12 @@ namespace SparkleShare {
string event_entry_html = EventEntryHTML;
string event_log = "";
event_entry_html = event_entry_html
.Replace ("Add note", _ ("Add note"))
.Replace ("Show all", _ ("Show all"));
event_log_html = event_log_html
.Replace ("Show all", _ ("Show all"));
foreach (ActivityDay activity_day in activity_days) {
string event_entries = "";
@ -600,6 +602,7 @@ namespace SparkleShare {
};
repo.ConflictResolved += delegate {
Program.SetUiCulture();
if (ConflictNotificationRaised != null)
ConflictNotificationRaised ();
};

View file

@ -46,7 +46,7 @@ namespace SparkleShare {
// Short alias for the translations
public static string _(string s)
{
return s;
return Program._ (s);
}

View file

@ -20,6 +20,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
@ -48,14 +49,27 @@ namespace SparkleShare {
return Strings.T(s);
#endif
}
#if !__MonoCS__
public static void TranslateWinForm (System.Windows.Forms.Form form)
{
form.Text = Program._ (form.Text);
foreach (var label in form.Controls.All ().OfType<System.Windows.Forms.Label> ()) {
label.Text = Program._ (label.Text);
}
foreach (var button in form.Controls.All ().OfType<System.Windows.Forms.Button> ()) {
button.Text = Program._ (button.Text);
}
}
#endif
#if !__MonoCS__
[STAThread]
#endif
public static void Main (string [] args)
{
//var culture = CultureInfo.GetCultureInfo ("en"); // FIXME: test only
//System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
SetUiCulture();
// Parse the command line options
bool show_help = false;
@ -96,6 +110,12 @@ namespace SparkleShare {
#endif
}
public static void SetUiCulture()
{
//var culture = CultureInfo.GetCultureInfo ("en"); // FIXME: test only
//System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
}
// Prints the help output
public static void ShowHelp (OptionSet option_set)

View file

@ -18,6 +18,7 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows.Forms;
@ -32,7 +33,7 @@ namespace SparkleShare {
// Short alias for the translations
public static string _(string s)
{
return s;
return Program._(s);
}
@ -49,6 +50,8 @@ namespace SparkleShare {
this.MinimumSize = this.Size;
this.version.Text = "";
Program.TranslateWinForm (this);
Controller.NewVersionEvent += delegate (string new_version) {
this.version.Invoke((Action)delegate {
this.version.Text = new_version;

View file

@ -44,13 +44,15 @@ namespace SparkleShare {
// Short alias for the translations
public static string _ (string s)
{
return s;
return Program._ (s);
}
public SparkleEventLog ()
{
InitializeComponent ();
Program.TranslateWinForm (this);
this.Icon = Icons.sparkleshare;
this.change_sets = Program.Controller.GetLog (null);
@ -87,6 +89,7 @@ namespace SparkleShare {
public void UpdateEvents (bool silent)
{
Thread thread = new Thread (new ThreadStart (delegate {
Program.SetUiCulture ();
Stopwatch watch = new Stopwatch ();
watch.Start ();
this.change_sets = Program.Controller.GetLog (this.selected_log);

View file

@ -45,9 +45,10 @@ namespace SparkleShare {
this.buttonCancel = new System.Windows.Forms.Button ();
this.label4 = new System.Windows.Forms.Label ();
this.syncingPage = new System.Windows.Forms.TabPage ();
this.label16 = new System.Windows.Forms.Label ();
this.label15 = new System.Windows.Forms.Label ();
this.syncingProgressBar = new System.Windows.Forms.ProgressBar ();
this.buttonFinish = new System.Windows.Forms.Button ();
this.label7 = new System.Windows.Forms.Label ();
this.label6 = new System.Windows.Forms.Label ();
this.errorPage = new System.Windows.Forms.TabPage ();
this.buttonTryAgain = new System.Windows.Forms.Button ();
@ -118,7 +119,6 @@ namespace SparkleShare {
this.groupBox1.Size = new System.Drawing.Size (471, 102);
this.groupBox1.TabIndex = 7;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Information about you";
//
// EmailEntry
//
@ -152,9 +152,9 @@ namespace SparkleShare {
this.label12.Font = new System.Drawing.Font ("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label12.Location = new System.Drawing.Point (15, 31);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size (65, 13);
this.label12.Size = new System.Drawing.Size (67, 13);
this.label12.TabIndex = 7;
this.label12.Text = "Full name:";
this.label12.Text = "Full Name:";
//
// label11
//
@ -163,7 +163,7 @@ namespace SparkleShare {
this.label11.Size = new System.Drawing.Size (307, 62);
this.label11.TabIndex = 2;
this.label11.Text = "Before we can create a SparkleShare folder on this computer, we need a few bits o" +
"f information from you.\r\n";
"f information from you.";
//
// label10
//
@ -178,7 +178,7 @@ namespace SparkleShare {
// buttonNext
//
this.buttonNext.Enabled = false;
this.buttonNext.Location = new System.Drawing.Point (410, 316);
this.buttonNext.Location = new System.Drawing.Point (416, 339);
this.buttonNext.Name = "buttonNext";
this.buttonNext.Size = new System.Drawing.Size (75, 23);
this.buttonNext.TabIndex = 0;
@ -230,9 +230,9 @@ namespace SparkleShare {
this.label5.Font = new System.Drawing.Font ("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point (197, 267);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size (113, 20);
this.label5.Size = new System.Drawing.Size (114, 20);
this.label5.TabIndex = 15;
this.label5.Text = "Remote path";
this.label5.Text = "Remote Path";
//
// label14
//
@ -258,7 +258,7 @@ namespace SparkleShare {
this.buttonSync.Name = "buttonSync";
this.buttonSync.Size = new System.Drawing.Size (75, 23);
this.buttonSync.TabIndex = 9;
this.buttonSync.Text = "Sync";
this.buttonSync.Text = "Add";
this.buttonSync.UseVisualStyleBackColor = true;
this.buttonSync.Click += new System.EventHandler (this.buttonSync_Click);
//
@ -278,15 +278,16 @@ namespace SparkleShare {
this.label4.Font = new System.Drawing.Font ("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point (8, 18);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size (68, 20);
this.label4.Size = new System.Drawing.Size (243, 20);
this.label4.TabIndex = 0;
this.label4.Text = "Header";
this.label4.Text = "Where\'s your project hosted?";
//
// syncingPage
//
this.syncingPage.Controls.Add (this.label16);
this.syncingPage.Controls.Add (this.label15);
this.syncingPage.Controls.Add (this.syncingProgressBar);
this.syncingPage.Controls.Add (this.buttonFinish);
this.syncingPage.Controls.Add (this.label7);
this.syncingPage.Controls.Add (this.label6);
this.syncingPage.Location = new System.Drawing.Point (4, 22);
this.syncingPage.Name = "syncingPage";
@ -295,6 +296,24 @@ namespace SparkleShare {
this.syncingPage.Text = "Syncing";
this.syncingPage.UseVisualStyleBackColor = true;
//
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point (11, 57);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size (176, 13);
this.label16.TabIndex = 5;
this.label16.Text = "Are you sure its not coffee o\'clock?";
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point (11, 44);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size (112, 13);
this.label15.TabIndex = 4;
this.label15.Text = "This may take a while.";
//
// syncingProgressBar
//
this.syncingProgressBar.Location = new System.Drawing.Point (14, 109);
@ -305,7 +324,7 @@ namespace SparkleShare {
// buttonFinish
//
this.buttonFinish.Enabled = false;
this.buttonFinish.Location = new System.Drawing.Point (431, 350);
this.buttonFinish.Location = new System.Drawing.Point (416, 339);
this.buttonFinish.Name = "buttonFinish";
this.buttonFinish.Size = new System.Drawing.Size (75, 23);
this.buttonFinish.TabIndex = 2;
@ -313,23 +332,15 @@ namespace SparkleShare {
this.buttonFinish.UseVisualStyleBackColor = true;
this.buttonFinish.Click += new System.EventHandler (this.buttonFinish_Click);
//
// label7
//
this.label7.Location = new System.Drawing.Point (11, 44);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size (307, 62);
this.label7.TabIndex = 1;
this.label7.Text = "This may take a while.\r\nAre you sure its not coffee o\'clock?\r\n";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font ("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold);
this.label6.Location = new System.Drawing.Point (8, 18);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size (123, 20);
this.label6.Size = new System.Drawing.Size (79, 20);
this.label6.TabIndex = 0;
this.label6.Text = "Syncing folder";
this.label6.Text = "Syncing";
//
// errorPage
//
@ -346,11 +357,11 @@ namespace SparkleShare {
//
// buttonTryAgain
//
this.buttonTryAgain.Location = new System.Drawing.Point (380, 319);
this.buttonTryAgain.Location = new System.Drawing.Point (416, 339);
this.buttonTryAgain.Name = "buttonTryAgain";
this.buttonTryAgain.Size = new System.Drawing.Size (75, 23);
this.buttonTryAgain.TabIndex = 3;
this.buttonTryAgain.Text = "Try Again";
this.buttonTryAgain.Text = "Try Again";
this.buttonTryAgain.UseVisualStyleBackColor = true;
this.buttonTryAgain.Click += new System.EventHandler (this.buttonTryAgain_Click);
//
@ -400,7 +411,7 @@ namespace SparkleShare {
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size (307, 62);
this.label9.TabIndex = 3;
this.label9.Text = "Access the synced files from your SparkleShare folder.";
this.label9.Text = "Access the files from your SparkleShare folder.";
//
// label8
//
@ -408,13 +419,13 @@ namespace SparkleShare {
this.label8.Font = new System.Drawing.Font ("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold);
this.label8.Location = new System.Drawing.Point (8, 18);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size (228, 20);
this.label8.Size = new System.Drawing.Size (227, 20);
this.label8.TabIndex = 2;
this.label8.Text = "Folder synced successfully!";
this.label8.Text = "Project successfully added!";
//
// buttonFinished
//
this.buttonFinished.Location = new System.Drawing.Point (399, 318);
this.buttonFinished.Location = new System.Drawing.Point (416, 339);
this.buttonFinished.Name = "buttonFinished";
this.buttonFinished.Size = new System.Drawing.Size (75, 23);
this.buttonFinished.TabIndex = 1;
@ -424,7 +435,7 @@ namespace SparkleShare {
//
// buttonOpenFolder
//
this.buttonOpenFolder.Location = new System.Drawing.Point (318, 318);
this.buttonOpenFolder.Location = new System.Drawing.Point (335, 339);
this.buttonOpenFolder.Name = "buttonOpenFolder";
this.buttonOpenFolder.Size = new System.Drawing.Size (75, 23);
this.buttonOpenFolder.TabIndex = 0;
@ -476,7 +487,6 @@ namespace SparkleShare {
private System.Windows.Forms.Button buttonSync;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.PictureBox pictureBox;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button buttonFinish;
private System.Windows.Forms.ProgressBar syncingProgressBar;
@ -498,6 +508,8 @@ namespace SparkleShare {
private System.Windows.Forms.Label label14;
private SparkleShare.controls.ExampleTextBox FolderEntry;
private SparkleShare.controls.ExampleTextBox ServerEntry;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.Label label15;

View file

@ -37,17 +37,14 @@ namespace SparkleShare {
// Short alias for the translations
public static string _ (string s) {
return s;
return Program._ (s);
}
public SparkleSetup () {
InitializeComponent ();
/* Support translations for the UI */
this.label5.Text = _ ("Remote path");
this.label14.Text = _ ("Address");
this.label4.Text = _ ("Where is your remote folder?");
Program.TranslateWinForm (this);
pictureBox.Image = Icons.side_splash;
this.Icon = Icons.sparkleshare;

View file

@ -39,7 +39,7 @@ namespace SparkleShare {
// Short alias for the translations
public static string _ (string s)
{
return s;
return Program._ (s);
}
@ -187,7 +187,7 @@ namespace SparkleShare {
Menu.Items.Add (new ToolStripSeparator ());
// Opens the wizard to add a new remote folder
ToolStripMenuItem sync_item = new ToolStripMenuItem (_ ("Add Remote Folder…"));
ToolStripMenuItem sync_item = new ToolStripMenuItem (_ ("Add Hosted Project…"));
if (Program.Controller.FirstRun)
sync_item.Enabled = false;
@ -206,7 +206,7 @@ namespace SparkleShare {
Menu.Items.Add (sync_item);
Menu.Items.Add (new ToolStripSeparator ());
ToolStripMenuItem recent_events_item = new ToolStripMenuItem (_ ("Show Recent Events"));
ToolStripMenuItem recent_events_item = new ToolStripMenuItem (_ ("Open Recent Events"));
if (Program.Controller.Folders.Count < 1)
recent_events_item.Enabled = false;

View file

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Collections.Generic;
using System.Windows.Forms;
using SparkleLib;
using System;
using System.IO;
@ -38,5 +40,16 @@ namespace SparkleShare {
{
return String.Format ("#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B);
}
//http://stackoverflow.com/a/1499161/33499
public static IEnumerable<Control> All (this Control.ControlCollection controls)
{
foreach (Control control in controls) {
foreach (Control grandChild in control.Controls.All ())
yield return grandChild;
yield return control;
}
}
}
}