Permalink
Browse files

add basic translation support

  • Loading branch information...
hbons committed May 18, 2010
1 parent 84cd349 commit 5d7d629396e2fecbcecbe0fe4d425e1393e59d25
View
@@ -1,3 +1,4 @@
*~
*.exe
*.exe.mdb
+*.userprefs
View
1 README
@@ -66,6 +66,7 @@ You can build and install SparkleShare like this:
$ make
$ sudo make install
+
Frequently Asked Question
=========================
@@ -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;
@@ -26,6 +27,11 @@ namespace SparkleShare {
// name and url to sync changes with
public class SparkleDialog : Window {
+ // Short alias for the translations
+ public static string _ (string s) {
+ return Catalog.GetString (s);
+ }
+
private Button AddButton;
private ComboBoxEntry RemoteUrlCombo;
private Entry NameEntry;
@@ -37,19 +43,19 @@ public class SparkleDialog : Window {
Modal = true;
Resizable = false;
SetPosition (WindowPosition.Center);
- Title = "Add a Folder";
+ Title = _("Add a Folder");
VBox VBox = new VBox (false, 0);
- Label NameLabel = new Label ("Folder Name: ");
+ Label NameLabel = new Label (_("Folder Name: "));
NameEntry = new Entry ();
- Label NameExample = new Label ("<span size='small'><i>Example: " +
- "‘Project’.</i></span>");
+ Label NameExample = new Label (_("<span size='small'><i>Example: ") +
+ _("‘Project’.</i></span>"));
NameExample.UseMarkup = true;
NameExample.SetAlignment (0, 0);
NameLabel.Xalign = 1;
- Label RemoteUrlLabel = new Label ("Remote address: ");
+ Label RemoteUrlLabel = new Label (_("Remote address: "));
string [] DefaultUrls = new string [4] { "ssh://git@github.com",
"ssh://git@git.gnome.org",
@@ -58,8 +64,8 @@ public class SparkleDialog : Window {
RemoteUrlCombo = new ComboBoxEntry (DefaultUrls);
- Label RemoteUrlExample = new Label ("<span size='small'><i>Example: " +
- "‘ssh://git@github.com’.</i></span>");
+ Label RemoteUrlExample = new Label (_("<span size='small'><i>Example: ") +
+ _("‘ssh://git@github.com’.</i></span>"));
RemoteUrlExample.UseMarkup = true;
RemoteUrlExample.SetAlignment (0, 0);
RemoteUrlLabel.Xalign = 1;
@@ -109,8 +115,8 @@ public class SparkleDialog : Window {
Remove (Child);
VBox Box = new VBox (false, 24);
SparkleSpinner Spinner = new SparkleSpinner ();
- Label Label = new Label ("Downloading files,\n" +
- "this may take a while...");
+ Label Label = new Label (_("Downloading files,\n") +
+ _("this may take a while..."));
Box.PackStart (Spinner, false, false, 0);
Box.PackStart (Label, false, false, 0);
BorderWidth = 30;
@@ -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;
@@ -26,29 +27,34 @@ namespace SparkleShare {
// name and url to sync changes with
public class SparklePreferencesDialog : Window {
+ // Short alias for the translations
+ public static string _ (string s) {
+ return Catalog.GetString (s);
+ }
+
public SparklePreferencesDialog (SparkleWindow SparkleWindow,
SparkleRepo SparkleRepo) : base ("") {
BorderWidth = 12;
IconName = "folder-sparkleshare";
Resizable = false;
SetPosition (WindowPosition.Center);
- Title = "Preferences";
+ Title = _("Preferences");
TransientFor = SparkleWindow;
VBox LayoutVertical = new VBox (false, 0);
Label InfoLabel = new Label ();
- InfoLabel.Text = "The folder " +
+ InfoLabel.Text = _("The folder ") +
"<b>" + SparkleRepo.LocalPath + "</b>" +
- "\nis linked to " +
+ _("\nis linked to ") +
"<b>" + SparkleRepo.RemoteOriginUrl + "</b>";
InfoLabel.Xalign = 0;
InfoLabel.UseMarkup = true;
CheckButton NotifyChangesCheckButton =
- new CheckButton ("Notify me when something changes");
+ new CheckButton (_("Notify me when something changes"));
string NotifyChangesFileName =
SparkleHelpers.CombineMore (SparkleRepo.LocalPath,
@@ -68,7 +74,7 @@ public class SparklePreferencesDialog : Window {
};
CheckButton SyncChangesCheckButton =
- new CheckButton ("Synchronize my changes");
+ new CheckButton (_("Synchronize my changes"));
string SyncChangesFileName =
SparkleHelpers.CombineMore (SparkleRepo.LocalPath,
@@ -15,19 +15,28 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using Gtk;
+using Mono.Unix;
using System;
using System.Diagnostics;
namespace SparkleShare {
// This is SparkleShare!
public class SparkleShare {
+
+ // Short alias for the translations
+ public static string _ (string s) {
+ return Catalog.GetString (s);
+ }
public static SparkleRepo [] Repositories;
public static SparkleUI SparkleUI;
public static void Main (string [] args) {
+ // Use translations
+ Catalog.Init ("i18n", "locale");
+
// Check if git is installed
Process Process = new Process();
Process.StartInfo.FileName = "git";
@@ -36,17 +45,17 @@ public class SparkleShare {
Process.Start();
if (Process.StandardOutput.ReadToEnd().IndexOf ("version") == -1) {
- Console.WriteLine ("Git wasn't found.");
- Console.WriteLine ("You can get it from http://git-scm.com/.");
+ Console.WriteLine (_("Git wasn't found."));
+ Console.WriteLine (_("You can get Git from http://git-scm.com/."));
Environment.Exit (0);
}
// Don't allow running as root
Process.StartInfo.FileName = "whoami";
Process.Start();
if (Process.StandardOutput.ReadToEnd().Trim ().Equals ("root")) {
- Console.WriteLine ("Sorry, you can't run SparkleShare as root.");
- Console.WriteLine ("Things will go utterly wrong.");
+ Console.WriteLine (_("Sorry, you can't run SparkleShare with these permissions."));
+ Console.WriteLine (_("Things will go utterly wrong."));
Environment.Exit (0);
}
@@ -73,21 +82,21 @@ public class SparkleShare {
// Prints the help output
public static void ShowHelp () {
- Console.WriteLine ("SparkleShare Copyright (C) 2010 Hylke Bons");
- Console.WriteLine ("");
- Console.WriteLine ("This program comes with ABSOLUTELY NO WARRANTY.");
- Console.WriteLine ("This is free software, and you are welcome to redistribute it ");
- Console.WriteLine ("under certain conditions. Please read the GNU GPLv3 for details.");
- Console.WriteLine ("");
- Console.WriteLine ("SparkleShare syncs the ~/SparkleShare folder with remote repositories.");
- Console.WriteLine ("");
- Console.WriteLine ("Usage: sparkleshare [start|stop|restart] [OPTION]...");
- Console.WriteLine ("Sync SparkleShare folder with remote repositories.");
- Console.WriteLine ("");
- Console.WriteLine ("Arguments:");
- Console.WriteLine ("\t -d, --disable-gui\tDon't show the notification icon.");
- Console.WriteLine ("\t -h, --help\t\tDisplay this help text.");
- Console.WriteLine ("");
+ Console.WriteLine (_("SparkleShare Copyright (C) 2010 Hylke Bons"));
+ Console.WriteLine (" ");
+ Console.WriteLine (_("This program comes with ABSOLUTELY NO WARRANTY."));
+ Console.WriteLine (_("This is free software, and you are welcome to redistribute it "));
+ Console.WriteLine (_("under certain conditions. Please read the GNU GPLv3 for details."));
+ Console.WriteLine (" ");
+ Console.WriteLine (_("SparkleShare syncs the ~/SparkleShare folder with remote repositories."));
+ Console.WriteLine (" ");
+ Console.WriteLine (_("Usage: sparkleshare [start|stop|restart] [OPTION]..."));
+ Console.WriteLine (_("Sync SparkleShare folder with remote repositories."));
+ Console.WriteLine (" ");
+ Console.WriteLine (_("Arguments:"));
+ Console.WriteLine (_("\t -d, --disable-gui\tDon't show the notification icon."));
+ Console.WriteLine (_("\t -h, --help\t\tDisplay this help text."));
+ Console.WriteLine (" ");
Environment.Exit (0);
}
@@ -31,6 +31,7 @@
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="notify-sharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=2df29c54e245917a" />
<Reference Include="System" />
+ <Reference Include="Mono.Posix" />
</ItemGroup>
<ItemGroup>
<Compile Include="SparkleBubble.cs" />
Binary file not shown.
@@ -15,21 +15,27 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using Gtk;
+using Mono.Unix;
using SparkleShare;
using System;
using System.Diagnostics;
namespace SparkleShare {
-
+
public class SparkleStatusIcon : StatusIcon {
+ // Short alias for the translations
+ public static string _ (string s) {
+ return Catalog.GetString (s);
+ }
+
public SparkleStatusIcon () : base () {
Activate += delegate {
Menu Menu = new Menu();
- MenuItem OpenFolderItem = new MenuItem ("Open Sharing Folder");
+ MenuItem OpenFolderItem = new MenuItem (_("Open Sharing Folder"));
OpenFolderItem.Activated += delegate {
Process Process = new Process ();
Process.StartInfo.FileName = "xdg-open";
@@ -39,7 +45,7 @@ public class SparkleStatusIcon : StatusIcon {
Menu.Add (OpenFolderItem);
Menu.Add (new SeparatorMenuItem ());
- MenuItem StatusItem = new MenuItem ("Everything up to date");
+ MenuItem StatusItem = new MenuItem (_("Everything is up to date"));
StatusItem.Sensitive = false;
Menu.Add (StatusItem);
@@ -59,7 +65,7 @@ public class SparkleStatusIcon : StatusIcon {
}
Menu.Add (new SeparatorMenuItem ());
- MenuItem AboutItem = new MenuItem ("About SparkleShare");
+ MenuItem AboutItem = new MenuItem (_("About SparkleShare"));
AboutItem.Activated += delegate {
Process Process = new Process ();
Process.StartInfo.FileName = "xdg-open";
@@ -69,7 +75,7 @@ public class SparkleStatusIcon : StatusIcon {
Menu.Add(AboutItem);
Menu.Add (new SeparatorMenuItem ());
- MenuItem QuitItem = new MenuItem ("Quit");
+ MenuItem QuitItem = new MenuItem (Gtk.Stock.Quit);
QuitItem.Activated += delegate { Environment.Exit (0); };
Menu.Add(QuitItem);
@@ -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;
@@ -26,6 +27,11 @@ namespace SparkleShare {
public class SparkleWindow : Window {
+ // Short alias for the translations
+ public static string _ (string s) {
+ return Catalog.GetString (s);
+ }
+
private SparkleRepo SparkleRepo;
public SparkleWindow (SparkleRepo Repo) : base ("") {
@@ -40,7 +46,7 @@ public class SparkleWindow : Window {
SetSizeRequest (900, 480);
SetPosition (WindowPosition.Center);
BorderWidth = 6;
- Title = "Happenings in ‘" + SparkleRepo.Name + "";
+ Title = _("Happenings in ‘" + SparkleRepo.Name + "");
IconName = "folder-sparkleshare";
VBox LayoutVertical = new VBox (false, 0);
@@ -221,7 +227,7 @@ public class SparkleWindow : Window {
// Do something special if the person is you
if (UserName.Equals (SparkleRepo.UserName))
- UserName += " (that’s you!)";
+ UserName += _(" (that’s you!)");
// Actually add to the list
PeopleIter = PeopleStore.Prepend ();
View
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+mkdir -p locale
+if [ $# -ne 1 ]; then
+ echo "Usage: ./create-po-file [LOCALE].po"
+else
+ xgettext -a --from-code=UTF-8 SparkleShare/*.cs -o locale/$1
+ echo "Created locale/$1."
+fi
Oops, something went wrong.

0 comments on commit 5d7d629

Please sign in to comment.