[four-in-a-row] Status messages should be easier to localize now.



commit 39413722322ad50adf39b33e7d88f65db84bd1ab
Author: Nikhar Agrawal <nikharagrawal2006 gmail com>
Date:   Fri Mar 21 22:12:55 2014 +0530

    Status messages should be easier to localize now.
    
    Expanded the _Theme struct to now hold win
    and turn strings. Created two functions that
    return win and turn strings.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723511

 src/main.c  |   16 ++++++++++------
 src/theme.c |   39 +++++++++++++++++++++++++++++++++------
 src/theme.h |    4 ++++
 3 files changed, 47 insertions(+), 12 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index 06eb906..ddc6234 100644
--- a/src/main.c
+++ b/src/main.c
@@ -529,20 +529,24 @@ prompt_player (void)
     break;
   case 2:
   case 0:
-    if (player == PLAYER1)
-       who = _(theme_get_player (PLAYER1));
-    else
-       who = _(theme_get_player (PLAYER2));
 
     if (gameover) {
-       str = g_strdup_printf (_("%s wins!"), who);
+       if (player == PLAYER1)
+         who = _(theme_get_player_win (PLAYER1));
+       else
+         who = _(theme_get_player_win (PLAYER2));
+       str = g_strdup_printf (_("%s"), who);
       }
     else if (player_active) {
       set_status_message (_("Your Turn"));
       return;
 
     } else {
-      str = g_strdup_printf (_("%s’s Turn"), who);
+       if (player == PLAYER1)
+         who = _(theme_get_player_turn (PLAYER1));
+       else
+         who = _(theme_get_player_turn (PLAYER2));
+        str = g_strdup_printf (_("%s"), who);
     }
 
     set_status_message (str);
diff --git a/src/theme.c b/src/theme.c
index 8426fea..bc2e8d4 100644
--- a/src/theme.c
+++ b/src/theme.c
@@ -41,40 +41,50 @@ Theme theme[] = {
    "tileset_50x50_hcontrast.svg",
    NULL,
    "#000000",
-   N_("Circle"), N_("Cross")
+   N_("Circle"), N_("Cross"),
+   N_("Circle wins!"), N_("Cross wins!"),
+   N_("Circle’s turn"), N_("Cross’s turn")
    },
   {
    N_("High Contrast Inverse"),
    "tileset_50x50_hcinverse.svg",
    NULL,
    "#FFFFFF",
-   N_("Circle"), N_("Cross")
+   N_("Circle"), N_("Cross"),
+   N_("Circle wins!"), N_("Cross wins!"),
+   N_("Circle’s turn"), N_("Cross’s turn")
    },
   {
    N_("Red and Green Marbles"),
    "tileset_50x50_faenza-glines-icon1.svg",
    "bg_toplight.png",
    "#727F8C",
-   N_("Red"), N_("Green")
+   N_("Red"), N_("Green"),
+   N_("Red wins!"), N_("Green wins!"),
+   N_("Red’s turn"), N_("Green’s turn")
    },
   {
    N_("Blue and Red Marbles"),
    "tileset_50x50_faenza-glines-icon2.svg",
    "bg_toplight.png",
    "#727F8C",
-   N_("Blue"), N_("Red")
+   N_("Blue"), N_("Red"),
+   N_("Blue wins!"), N_("Red wins!"),
+   N_("Blue’s turn"), N_("Red’s turn")
    },
   {
    N_("Stars and Rings"),
    "tileset_50x50_faenza-gnect-icon.svg",
    "bg_toplight.png",
    "#727F8C",
-   N_("Red"), N_("Green")
+   N_("Red"), N_("Green"),
+   N_("Red wins!"), N_("Green wins!"),
+   N_("Red’s turn"), N_("Green’s turn")
    }
 };
 
-gint n_themes = G_N_ELEMENTS (theme);
 
+gint n_themes = G_N_ELEMENTS (theme);
 
 
 const gchar *
@@ -86,6 +96,23 @@ theme_get_player (PlayerID who)
 }
 
 
+const gchar *
+theme_get_player_win (PlayerID who)
+{
+  if (who == PLAYER1)
+    return theme[p.theme_id].player1_win;
+  return theme[p.theme_id].player2_win;
+}
+
+
+
+const gchar *
+theme_get_player_turn (PlayerID who)
+{
+  if (who == PLAYER1)
+    return theme[p.theme_id].player1_turn;
+  return theme[p.theme_id].player2_turn;
+}
 
 const gchar *
 theme_get_title (gint id)
diff --git a/src/theme.h b/src/theme.h
index f2ea52c..f881b57 100644
--- a/src/theme.h
+++ b/src/theme.h
@@ -10,6 +10,10 @@ struct _Theme {
   const gchar *grid_color;
   const gchar *player1;
   const gchar *player2;
+  const gchar *player1_win;
+  const gchar *player2_win;
+  const gchar *player1_turn;
+  const gchar *player2_turn;
 };
 
 


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