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.
This commit is contained in:
Łukasz Jernaś 2010-06-10 23:44:58 +02:00
parent 8c41cdcb13
commit cae67bf348
4 changed files with 19 additions and 13 deletions

View file

@ -123,7 +123,7 @@ namespace SparkleShare {
SparkleBubble SyncingBubble = SparkleBubble SyncingBubble =
new SparkleBubble (_("Syncing folder ") + RepoName + "", new SparkleBubble (String.Format(_("Syncing folder {0}"), RepoName),
_("SparkleShare will notify you ") + _("SparkleShare will notify you ") +
_("when this is done.")); _("when this is done."));
@ -160,8 +160,7 @@ namespace SparkleShare {
if (Output.Contains ("fatal:")) { if (Output.Contains ("fatal:")) {
SparkleBubble ErrorBubble = SparkleBubble ErrorBubble =
new SparkleBubble ("Something went wrong while syncing " + new SparkleBubble (String.Format(_("Something went wrong while syncing {0}"), RepoName),
" " + RepoName + "",
"Please double check the address and\n" + "Please double check the address and\n" +
"network connection."); "network connection.");
@ -204,11 +203,10 @@ namespace SparkleShare {
// Show a confirmation notification // Show a confirmation notification
SparkleBubble FinishedBubble = SparkleBubble FinishedBubble =
new SparkleBubble (_("Successfully synced folder ") + new SparkleBubble (String.Format(_("Successfully synced folder {0}"), RepoName),
"" + RepoName + "",
_("Now make great stuff happen!")); _("Now make great stuff happen!"));
FinishedBubble.AddAction ("", _("Open Folder"), FinishedBubble.AddAction ("", _("Open Folder"),
delegate { delegate {
Process.StartInfo.FileName = "xdg-open"; Process.StartInfo.FileName = "xdg-open";
Process.StartInfo.Arguments = Process.StartInfo.Arguments =

View file

@ -28,6 +28,10 @@ namespace SparkleShare {
// SparkleRepo class holds repository information and timers // SparkleRepo class holds repository information and timers
public class SparkleRepo { public class SparkleRepo {
public static string _ (string s) {
return Catalog.GetString (s);
}
private Process Process; private Process Process;
private Timer FetchTimer; private Timer FetchTimer;
private Timer BufferTimer; private Timer BufferTimer;
@ -465,7 +469,7 @@ namespace SparkleShare {
// Add a button to open the folder where the changed file is // Add a button to open the folder where the changed file is
if (ShowButtons) if (ShowButtons)
StuffChangedBubble.AddAction StuffChangedBubble.AddAction
("", "Open Folder", ("", _("Open Folder"),
delegate { delegate {
switch (SparklePlatform.Name) { switch (SparklePlatform.Name) {
case "GNOME": case "GNOME":

View file

@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using Gtk; using Gtk;
using Mono.Unix;
using SparkleShare; using SparkleShare;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
@ -24,6 +25,11 @@ namespace SparkleShare {
public class SparkleUI { public class SparkleUI {
// Short alias for the translations
public static string _ (string s) {
return Catalog.GetString (s);
}
public static SparkleStatusIcon NotificationIcon; public static SparkleStatusIcon NotificationIcon;
public SparkleUI (bool HideUI) { public SparkleUI (bool HideUI) {
@ -118,12 +124,11 @@ namespace SparkleShare {
if (SparkleShare.Repositories.Length == 0) { if (SparkleShare.Repositories.Length == 0) {
SparkleBubble NoFoldersBubble; SparkleBubble NoFoldersBubble;
NoFoldersBubble = new SparkleBubble ("Welcome to SparkleShare!", NoFoldersBubble = new SparkleBubble (_("Welcome to SparkleShare!"),
"You don't have any " + _("You don't have any folders set up yet."));
"folders set up yet.");
NoFoldersBubble.IconName = "folder-sparkleshare"; NoFoldersBubble.IconName = "folder-sparkleshare";
NoFoldersBubble.AddAction ("", "Add a Folder…", delegate { NoFoldersBubble.AddAction ("", _("Add a Folder…"), delegate {
SparkleDialog SparkleDialog = new SparkleDialog (""); SparkleDialog SparkleDialog = new SparkleDialog ("");
SparkleDialog.ShowAll (); SparkleDialog.ShowAll ();
/* Process.StartInfo.FileName = "xdg-open"; /* Process.StartInfo.FileName = "xdg-open";

View file

@ -46,8 +46,7 @@ namespace SparkleShare {
SetSizeRequest (720, 540); SetSizeRequest (720, 540);
SetPosition (WindowPosition.Center); SetPosition (WindowPosition.Center);
BorderWidth = 6; BorderWidth = 6;
Title = _("" + SparkleRepo.Name + " on " + Title = String.Format(_("{0} on {1}"), SparkleRepo.Name, SparkleRepo.RemoteOriginUrl
SparkleRepo.RemoteOriginUrl
.TrimEnd (("/" + SparkleRepo.Name + ".git").ToCharArray ())); .TrimEnd (("/" + SparkleRepo.Name + ".git").ToCharArray ()));
IconName = "folder"; IconName = "folder";