[gnome-nibbles/arnaudb/kill-preferences-dialog: 26/27] Translate "Number of players" screen.



commit 16e470fdbaea1959c7fc63a2512b13c1003d3289
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Jun 20 14:02:26 2020 +0200

    Translate "Number of players" screen.

 data/ui/players.ui | 15 ++++++++-------
 src/players.vala   | 50 ++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 54 insertions(+), 11 deletions(-)
---
diff --git a/data/ui/players.ui b/data/ui/players.ui
index 7ae9120..46c49a0 100644
--- a/data/ui/players.ui
+++ b/data/ui/players.ui
@@ -68,7 +68,8 @@
                   <object class="GtkToggleButton" id="players1">
                     <property name="visible">True</property>
                     <property name="use-underline">True</property>
-                    <property name="label">_1</property>
+                    <!-- Translators: in the "Number of players" configuration screen, label of a button 
allowing to play a solo game against AIs (with a mnemonic that appears when pressing Alt) -->
+                    <property name="label" translatable="yes">_1</property>
                     <property name="action-name">players.change-players-number</property>
                     <property name="action-target">@i 1</property>
                     <property name="sensitive" bind-source="players1" bind-property="active" 
bind-flags="invert-boolean"/>
@@ -81,7 +82,8 @@
                   <object class="GtkToggleButton" id="players2">
                     <property name="visible">True</property>
                     <property name="use-underline">True</property>
-                    <property name="label">_2</property>
+                    <!-- Translators: in the "Number of players" configuration screen, label of a button 
allowing to play game with 2 human players (with a mnemonic that appears when pressing Alt) -->
+                    <property name="label" translatable="yes">_2</property>
                     <property name="action-name">players.change-players-number</property>
                     <property name="action-target">@i 2</property>
                     <property name="sensitive" bind-source="players2" bind-property="active" 
bind-flags="invert-boolean"/>
@@ -94,7 +96,8 @@
                   <object class="GtkToggleButton" id="players3">
                     <property name="visible">True</property>
                     <property name="use-underline">True</property>
-                    <property name="label">_3</property>
+                    <!-- Translators: in the "Number of players" configuration screen, label of a button 
allowing to play game with 3 human players (with a mnemonic that appears when pressing Alt) -->
+                    <property name="label" translatable="yes">_3</property>
                     <property name="action-name">players.change-players-number</property>
                     <property name="action-target">@i 3</property>
                     <property name="sensitive" bind-source="players3" bind-property="active" 
bind-flags="invert-boolean"/>
@@ -107,7 +110,8 @@
                   <object class="GtkToggleButton" id="players4">
                     <property name="visible">True</property>
                     <property name="use-underline">True</property>
-                    <property name="label">_4</property>
+                    <!-- Translators: in the "Number of players" configuration screen, label of a button 
allowing to play game with 4 human players (with a mnemonic that appears when pressing Alt) -->
+                    <property name="label" translatable="yes">_4</property>
                     <property name="action-name">players.change-players-number</property>
                     <property name="action-target">@i 4</property>
                     <property name="sensitive" bind-source="players4" bind-property="active" 
bind-flags="invert-boolean"/>
@@ -144,7 +148,6 @@
                   <object class="GtkToggleButton" id="worms4">
                     <property name="visible">True</property>
                     <property name="use-underline">True</property>
-                    <property name="label">_3</property>
                     <property name="action-name">players.change-nibbles-number</property>
                     <property name="action-target">@i 4</property>
                     <property name="sensitive" bind-source="worms4" bind-property="active" 
bind-flags="invert-boolean"/>
@@ -157,7 +160,6 @@
                   <object class="GtkToggleButton" id="worms5">
                     <property name="visible">True</property>
                     <property name="use-underline">True</property>
-                    <property name="label">_4</property>
                     <property name="action-name">players.change-nibbles-number</property>
                     <property name="action-target">@i 5</property>
                     <property name="sensitive" bind-source="worms5" bind-property="active" 
bind-flags="invert-boolean"/>
@@ -170,7 +172,6 @@
                   <object class="GtkToggleButton" id="worms6">
                     <property name="visible">True</property>
                     <property name="use-underline">True</property>
-                    <property name="label">_5</property>
                     <property name="action-name">players.change-nibbles-number</property>
                     <property name="action-target">@i 6</property>
                     <property name="sensitive" bind-source="worms6" bind-property="active" 
bind-flags="invert-boolean"/>
diff --git a/src/players.vala b/src/players.vala
index a7117af..b81e6ba 100644
--- a/src/players.vala
+++ b/src/players.vala
@@ -28,6 +28,24 @@ private class Players : Box
     private SimpleAction nibbles_number_action;
     private SimpleAction players_number_action;
 
+    /* Translators: in the "Number of players" configuration screen, label of a button allowing to play game 
only with humans, appearing when there are 4 humans set (with a mnemonic that appears when pressing Alt) */
+    private const string ai0_label = N_("_0");
+
+    /* Translators: in the "Number of players" configuration screen, label of a button allowing to play game 
with one AI, appearing when there are 3 or 4 humans set (with a mnemonic that appears when pressing Alt) */
+    private const string ai1_label = N_("_1");
+
+    /* Translators: in the "Number of players" configuration screen, label of a button allowing to play game 
with two AIs, appearing when there are 2, 3 or 4 humans set (with a mnemonic that appears when pressing Alt) 
*/
+    private const string ai2_label = N_("_2");
+
+    /* Translators: in the "Number of players" configuration screen, label of a button allowing to play game 
with three AIs, appearing when there are 1, 2 or 3 humans set (with a mnemonic that appears when pressing 
Alt) */
+    private const string ai3_label = N_("_3");
+
+    /* Translators: in the "Number of players" configuration screen, label of a button allowing to play game 
with four AIs, appearing when there are 1 or 2 humans set (with a mnemonic that appears when pressing Alt) */
+    private const string ai4_label = N_("_4");
+
+    /* Translators: in the "Number of players" configuration screen, label of a button allowing to play game 
with five AIs, appearing when there is only 1 human set (with a mnemonic that appears when pressing Alt) */
+    private const string ai5_label = N_("_5");
+
     private const GLib.ActionEntry [] players_action_entries =
     {
         { "change-nibbles-number", null, "i", "4", change_nibbles_number },
@@ -69,11 +87,35 @@ private class Players : Box
 
     private void update_buttons_labels ()
     {
-        int min_ai = 4 - players_number_action.get_state ().get_int32 ();
+        switch (players_number_action.get_state ().get_int32 ())
+        {
+            case 1:
+                worms4.set_label (_(ai3_label));
+                worms5.set_label (_(ai4_label));
+                worms6.set_label (_(ai5_label));
+                break;
+
+            case 2:
+                worms4.set_label (_(ai2_label));
+                worms5.set_label (_(ai3_label));
+                worms6.set_label (_(ai4_label));
+                break;
+
+            case 3:
+                worms4.set_label (_(ai1_label));
+                worms5.set_label (_(ai2_label));
+                worms6.set_label (_(ai3_label));
+                break;
+
+            case 4:
+                worms4.set_label (_(ai0_label));
+                worms5.set_label (_(ai1_label));
+                worms6.set_label (_(ai2_label));
+                break;
 
-        worms4.set_label (@"_$min_ai");
-        worms5.set_label (@"_$(min_ai + 1)");
-        worms6.set_label (@"_$(min_ai + 2)");
+            default:
+                assert_not_reached ();
+        }
     }
 
     private inline void change_nibbles_number (SimpleAction _nibbles_number_action, Variant variant)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]