Use autotools and intltools, translate user interface, add German translation
[led-pattern-ed] / src / led-command-widget.vala
index 158e47a..fcbd34a 100644 (file)
@@ -42,49 +42,49 @@ class LedCommandWidget : Gtk.HBox {
                        button.set_sensitive (false);
                        break;
                case CommandType.RAMP_WAIT:
-                       button.set_title ((command.steps != 0) ? "Ramp" : "Wait");
+                       button.set_title ((command.steps != 0) ? _("Ramp") : _("Wait"));
                        button.set_value ((command.steps != 0) ?
-                                         "%+d steps, %.2f ms each".printf (command.steps,
-                                                                           command.step_time) :
+                                         _("%+d steps, %.2f ms each").printf (command.steps,
+                                                                              command.step_time) :
                                          "%.2f ms".printf (command.duration));
                        button.clicked.connect (on_ramp_wait_clicked);
                        break;
                case CommandType.SET_PWM:
-                       button.set_title ("Set PWM");
-                       button.set_value ("Level = %d".printf (command.level));
+                       button.set_title (_("Set PWM"));
+                       button.set_value (_("Level = %d").printf (command.level));
                        button.clicked.connect (on_set_pwm_clicked);
                        break;
                case CommandType.RESET_MUX:
-                       button.set_title ("Reset Mux");
+                       button.set_title (_("Reset Mux"));
                        break;
                case CommandType.GO_TO_START:
-                       button.set_title ("Go To Start");
+                       button.set_title (_("Go To Start"));
                        button.set_value ("");
                        button.clicked.connect (on_end_or_go_to_start_clicked);
                        break;
                case CommandType.BRANCH:
-                       button.set_title ("Branch");
+                       button.set_title (_("Branch"));
                        button.set_value ("0x%04x".printf (command.code));
                        button.set_sensitive (false);
                        break;
                case CommandType.END:
-                       button.set_title ("End");
-                       button.set_value ((command.steps == -255) ? "Reset" : "Hold");
+                       button.set_title (_("End"));
+                       button.set_value ((command.steps == -255) ? _("Reset") : _("Hold"));
                        button.clicked.connect (on_end_or_go_to_start_clicked);
                        break;
                case CommandType.TRIGGER:
-                       button.set_title ("Trigger");
+                       button.set_title (_("Trigger"));
                        string text = "";
                        if (0x0100 in command.code)
-                               text += "wait 2 ";
+                               text += _("wait 2 ");
                        if (0x0004 in command.code)
-                               text += "set 2 ";
+                               text += _("set 2 ");
                        if (0x0080 in command.code)
-                               text += "wait 1 ";
+                               text += _("wait 1 ");
                        if (0x0002 in command.code)
-                               text += "set 1 ";
+                               text += _("set 1 ");
                        if ((command.code & ~0xe186) != 0) {
-                               text = "Unsupported: 0x%04x".printf (command.code);
+                               text = _("Unsupported: 0x%04x").printf (command.code);
                                button.set_sensitive (false);
                        }
                        button.set_value (text);
@@ -98,7 +98,7 @@ class LedCommandWidget : Gtk.HBox {
                double old_step_time = command.step_time;
                int old_steps = command.steps;
                var dialog = new Gtk.Dialog ();
-               dialog.set_title ("Ramp / Wait");
+               dialog.set_title (_("Ramp / Wait"));
 
                var content = (Gtk.VBox) dialog.get_content_area ();
 
@@ -162,16 +162,16 @@ class LedCommandWidget : Gtk.HBox {
                content.pack_start (hbox, false, false, 0);
 
                content.show_all ();
-               dialog.add_button ("Delete", 1);
-               dialog.add_button ("Done", Gtk.ResponseType.OK);
+               dialog.add_button (_("Delete"), 1);
+               dialog.add_button (_("Done"), Gtk.ResponseType.OK);
 
                int response = dialog.run ();
                if (response == Gtk.ResponseType.OK) {
                        var button = source as Hildon.Button;
-                       button.set_title ((command.steps != 0) ? "Ramp" : "Wait");
+                       button.set_title ((command.steps != 0) ? _("Ramp") : _("Wait"));
                        button.set_value ((command.steps != 0) ?
-                                         "%+d steps, %.2f ms each".printf (command.steps,
-                                                                           command.step_time) :
+                                         _("%+d steps, %.2f ms each").printf (command.steps,
+                                                                              command.step_time) :
                                          "%.2f ms".printf (command.duration));
                } else if (response == 1) {
                        engine.remove (command);
@@ -186,7 +186,7 @@ class LedCommandWidget : Gtk.HBox {
        private void on_set_pwm_clicked (Gtk.Button source) {
                int old_level = command.level;
                var dialog = new Gtk.Dialog ();
-               dialog.set_title ("Set PWM");
+               dialog.set_title (_("Set PWM"));
 
                var content = (Gtk.VBox) dialog.get_content_area ();
 
@@ -203,15 +203,15 @@ class LedCommandWidget : Gtk.HBox {
                content.pack_start (scale, true, true, 0);
 
                content.show_all ();
-               dialog.add_button ("Delete", 1);
-               dialog.add_button ("Done", Gtk.ResponseType.OK);
+               dialog.add_button (_("Delete"), 1);
+               dialog.add_button (_("Done"), Gtk.ResponseType.OK);
 
                int response = dialog.run ();
                if (response == Gtk.ResponseType.OK) {
                        command.set_pwm ((int) scale.get_value ());
 
                        var button = source as Hildon.Button;
-                       button.set_value ("Level = %d".printf (command.level));
+                       button.set_value (_("Level = %d").printf (command.level));
                } else if (response == 1) {
                        engine.remove (command);
                        engine.first ().data.changed ();
@@ -228,9 +228,9 @@ class LedCommandWidget : Gtk.HBox {
                uint16 old_code = command.code;
                var dialog = new Gtk.Dialog ();
                if (command.type == CommandType.END)
-                       dialog.set_title ("End");
+                       dialog.set_title (_("End"));
                else
-                       dialog.set_title ("Go To Start");
+                       dialog.set_title (_("Go To Start"));
 
                var content = (Gtk.VBox) dialog.get_content_area ();
 
@@ -241,22 +241,22 @@ class LedCommandWidget : Gtk.HBox {
                var hbox = new Gtk.HBox (true, 0);
                var radio_end = (Gtk.RadioButton) Hildon.gtk_radio_button_new (Hildon.SizeType.FINGER_HEIGHT, null);
                radio_end.set_mode (false);
-               radio_end.set_label ("End");
+               radio_end.set_label (_("End"));
                hbox.pack_start (radio_end, true, true, 0);
                var radio_go_to_start = (Gtk.RadioButton) Hildon.gtk_radio_button_new_from_widget (Hildon.SizeType.FINGER_HEIGHT, radio_end);
                radio_go_to_start.set_mode (false);
-               radio_go_to_start.set_label ("Go To Start");
+               radio_go_to_start.set_label (_("Go To Start"));
                hbox.pack_start (radio_go_to_start, true, true, 0);
                content.pack_start (hbox, true, true, 0);
 
                hbox = new Gtk.HBox (true, 0);
                var radio_hold = (Gtk.RadioButton) Hildon.gtk_radio_button_new (Hildon.SizeType.FINGER_HEIGHT, null);
                radio_hold.set_mode (false);
-               radio_hold.set_label ("Hold");
+               radio_hold.set_label (_("Hold"));
                hbox.pack_start (radio_hold, true, true, 0);
                var radio_reset = (Gtk.RadioButton) Hildon.gtk_radio_button_new_from_widget (Hildon.SizeType.FINGER_HEIGHT, radio_hold);
                radio_reset.set_mode (false);
-               radio_reset.set_label ("Reset");
+               radio_reset.set_label (_("Reset"));
                hbox.pack_start (radio_reset, true, true, 0);
                content.pack_start (hbox, true, true, 0);
 
@@ -273,12 +273,12 @@ class LedCommandWidget : Gtk.HBox {
                                command.end (radio_reset.get_active ());
                                radio_hold.set_sensitive (true);
                                radio_reset.set_sensitive (true);
-                               dialog.set_title ("End");
+                               dialog.set_title (_("End"));
                        } else {
                                command.go_to_start ();
                                radio_hold.set_sensitive (false);
                                radio_reset.set_sensitive (false);
-                               dialog.set_title ("Go To Start");
+                               dialog.set_title (_("Go To Start"));
                        }
                        command.changed ();
                });
@@ -289,16 +289,16 @@ class LedCommandWidget : Gtk.HBox {
                });
 
                content.show_all ();
-               dialog.add_button ("Delete", 1);
-               dialog.add_button ("Done", Gtk.ResponseType.OK);
+               dialog.add_button (_("Delete"), 1);
+               dialog.add_button (_("Done"), Gtk.ResponseType.OK);
 
                int response = dialog.run ();
                if (response == Gtk.ResponseType.OK) {
                        var button = source as Hildon.Button;
                        button.set_value ((command.type == CommandType.END) ?
-                                         "End" : "Go To Start");
+                                         _("End") : _("Go To Start"));
                        button.set_value ((command.type == CommandType.END) ?
-                                         ((command.steps == -255) ? "Reset" : "Hold") : "");
+                                         ((command.steps == -255) ? _("Reset") : _("Hold")) : "");
                } else if (response == 1) {
                        engine.remove (command);
                        engine.first ().data.changed ();
@@ -315,7 +315,7 @@ class LedCommandWidget : Gtk.HBox {
        private void on_trigger_clicked (Gtk.Button source) {
                uint16 old_code = command.code;
                var dialog = new Gtk.Dialog ();
-               dialog.set_title ("Trigger");
+               dialog.set_title (_("Trigger"));
 
                var content = (Gtk.VBox) dialog.get_content_area ();
 
@@ -324,7 +324,7 @@ class LedCommandWidget : Gtk.HBox {
                content.pack_start (lpv, true, true, 0);
 
                var check = new Hildon.CheckButton (Hildon.SizeType.FINGER_HEIGHT);
-               check.set_label ("Set trigger");
+               check.set_label (_("Set trigger"));
                if ((command.code & 0x0006) != 0)
                        check.set_active (true);
                check.toggled.connect ((s) => {
@@ -338,7 +338,7 @@ class LedCommandWidget : Gtk.HBox {
                content.pack_start (check, true, true, 0);
 
                check = new Hildon.CheckButton (Hildon.SizeType.FINGER_HEIGHT);
-               check.set_label ("Wait for trigger");
+               check.set_label (_("Wait for trigger"));
                if ((command.code & 0x0180) != 0)
                        check.set_active (true);
                check.toggled.connect ((s) => {
@@ -352,23 +352,23 @@ class LedCommandWidget : Gtk.HBox {
                content.pack_start (check, true, true, 0);
 
                content.show_all ();
-               dialog.add_button ("Delete", 1);
-               dialog.add_button ("Done", Gtk.ResponseType.OK);
+               dialog.add_button (_("Delete"), 1);
+               dialog.add_button (_("Done"), Gtk.ResponseType.OK);
 
                int response = dialog.run ();
                if (response == Gtk.ResponseType.OK) {
                        var button = source as Hildon.Button;
                        string text = "";
                        if (0x0100 in command.code)
-                               text += "wait 2 ";
+                               text += _("wait 2 ");
                        if (0x0004 in command.code)
-                               text += "set 2 ";
+                               text += _("set 2 ");
                        if (0x0080 in command.code)
-                               text += "wait 1 ";
+                               text += _("wait 1 ");
                        if (0x0002 in command.code)
-                               text += "set 1 ";
+                               text += _("set 1 ");
                        if ((command.code & ~0xe186) != 0) {
-                               text = "Unsupported: 0x%04x".printf (command.code);
+                               text = _("Unsupported: 0x%04x").printf (command.code);
                                button.set_sensitive (false);
                        }
                        button.set_value (text);