From cae67bf348bb9e7314404cbd880ca3d287157490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Jerna=C5=9B?= Date: Thu, 10 Jun 2010 23:44:58 +0200 Subject: [PATCH] Properly handle strings with parameters String.Format should be used for strings which have variables inside. This assures that no context is lost for translators. --- SparkleShare/SparkleDialog.cs | 10 ++++------ SparkleShare/SparkleRepo.cs | 6 +++++- SparkleShare/SparkleUI.cs | 13 +++++++++---- SparkleShare/SparkleWindow.cs | 3 +-- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/SparkleShare/SparkleDialog.cs b/SparkleShare/SparkleDialog.cs index ff0c6981..ce6d3ffa 100644 --- a/SparkleShare/SparkleDialog.cs +++ b/SparkleShare/SparkleDialog.cs @@ -123,7 +123,7 @@ namespace SparkleShare { SparkleBubble SyncingBubble = - new SparkleBubble (_("Syncing folder ‘") + RepoName + "’", + new SparkleBubble (String.Format(_("Syncing folder ‘{0}’"), RepoName), _("SparkleShare will notify you ") + _("when this is done.")); @@ -160,8 +160,7 @@ namespace SparkleShare { if (Output.Contains ("fatal:")) { SparkleBubble ErrorBubble = - new SparkleBubble ("Something went wrong while syncing " + - " ‘" + RepoName + "’", + new SparkleBubble (String.Format(_("Something went wrong while syncing ‘{0}’"), RepoName), "Please double check the address and\n" + "network connection."); @@ -204,11 +203,10 @@ namespace SparkleShare { // Show a confirmation notification SparkleBubble FinishedBubble = - new SparkleBubble (_("Successfully synced folder ") + - "‘" + RepoName + "’", + new SparkleBubble (String.Format(_("Successfully synced folder ‘{0}’"), RepoName), _("Now make great stuff happen!")); - FinishedBubble.AddAction ("", _("Open Folder"), + FinishedBubble.AddAction ("", _("Open Folder"), delegate { Process.StartInfo.FileName = "xdg-open"; Process.StartInfo.Arguments = diff --git a/SparkleShare/SparkleRepo.cs b/SparkleShare/SparkleRepo.cs index de2627d5..bc6137bc 100644 --- a/SparkleShare/SparkleRepo.cs +++ b/SparkleShare/SparkleRepo.cs @@ -28,6 +28,10 @@ namespace SparkleShare { // SparkleRepo class holds repository information and timers public class SparkleRepo { + public static string _ (string s) { + return Catalog.GetString (s); + } + private Process Process; private Timer FetchTimer; private Timer BufferTimer; @@ -465,7 +469,7 @@ namespace SparkleShare { // Add a button to open the folder where the changed file is if (ShowButtons) StuffChangedBubble.AddAction - ("", "Open Folder", + ("", _("Open Folder"), delegate { switch (SparklePlatform.Name) { case "GNOME": diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index 9dd66d6e..93ca7e88 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -15,6 +15,7 @@ // along with this program. If not, see . using Gtk; +using Mono.Unix; using SparkleShare; using System; using System.Diagnostics; @@ -24,6 +25,11 @@ namespace SparkleShare { public class SparkleUI { + // Short alias for the translations + public static string _ (string s) { + return Catalog.GetString (s); + } + public static SparkleStatusIcon NotificationIcon; public SparkleUI (bool HideUI) { @@ -118,12 +124,11 @@ namespace SparkleShare { if (SparkleShare.Repositories.Length == 0) { SparkleBubble NoFoldersBubble; - NoFoldersBubble = new SparkleBubble ("Welcome to SparkleShare!", - "You don't have any " + - "folders set up yet."); + NoFoldersBubble = new SparkleBubble (_("Welcome to SparkleShare!"), + _("You don't have any folders set up yet.")); NoFoldersBubble.IconName = "folder-sparkleshare"; - NoFoldersBubble.AddAction ("", "Add a Folder…", delegate { + NoFoldersBubble.AddAction ("", _("Add a Folder…"), delegate { SparkleDialog SparkleDialog = new SparkleDialog (""); SparkleDialog.ShowAll (); /* Process.StartInfo.FileName = "xdg-open"; diff --git a/SparkleShare/SparkleWindow.cs b/SparkleShare/SparkleWindow.cs index cd3a8fea..c01914f3 100644 --- a/SparkleShare/SparkleWindow.cs +++ b/SparkleShare/SparkleWindow.cs @@ -46,8 +46,7 @@ namespace SparkleShare { SetSizeRequest (720, 540); SetPosition (WindowPosition.Center); BorderWidth = 6; - Title = _("‘" + SparkleRepo.Name + "’ on " + - SparkleRepo.RemoteOriginUrl + Title = String.Format(_("‘{0}’ on {1}"), SparkleRepo.Name, SparkleRepo.RemoteOriginUrl .TrimEnd (("/" + SparkleRepo.Name + ".git").ToCharArray ())); IconName = "folder";