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 =
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 =

View file

@ -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":

View file

@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
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";

View file

@ -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";