Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2003:
[Freeciv-Dev] (PR#6303) i18n problems in popup_info_text
Home

[Freeciv-Dev] (PR#6303) i18n problems in popup_info_text

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#6303) i18n problems in popup_info_text
From: "mateusz stefek" <matusik_s@xxxxx>
Date: Sat, 27 Sep 2003 09:19:36 -0700
Reply-to: rt@xxxxxxxxxxxxxx

This piece of code is really hard for polish translator(me)
The reason is that adjectives in diplo_adjectives[] are ment to be used  
in plural dative and singular nominative form.

Attached patch helps a bit, adds PL_() macros and removes stupid "\n"  
from translated strings

What do you think about it?

--
mateusz

--- freeorig/client/mapctrl_common.c    2003-09-23 18:44:35.000000000 +0200
+++ freeciv/client/mapctrl_common.c     2003-09-27 18:03:13.000000000 +0200
@@ -251,6 +251,17 @@
   return TRUE;
 }
 
+static void add_line(char* buf, char* line) 
+{
+  if (buf[0] == '\0') {
+    strcpy(buf, line);
+  } else {
+    int l = strlen(buf);
+    buf[l] = '\n';
+    strcpy(buf + l + 1, line);
+  }
+}
+
 /************************************************************************
 Text to popup on middle-click
 ************************************************************************/
@@ -261,40 +272,54 @@
   struct city *pcity = map_get_city(xtile, ytile);
   struct tile *ptile = map_get_tile(xtile, ytile);
   struct unit *punit = find_visible_unit(ptile);
-  char *diplo_adjectives[DS_LAST] = {_("Neutral"), _("Hostile"), 
_("Ceasefire"),
-                                    _("Peaceful"), _("Friendly"), 
_("Mysterious")};
+  char *diplo_nation_plural_adjectives[DS_LAST] = {Q_("?nation:Neutral"), 
+                                                   Q_("?nation:Hostile"),
+                                                  "" /* unused, DS_CEASEFIRE*/,
+                                                  Q_("?nation:Peaceful"),
+                                                  Q_("?nation:Friendly"), 
+                                                   Q_("?nation:Mysterious")};
+  char *diplo_city_adjectives[DS_LAST] = {Q_("?city:Neutral"),
+                                          Q_("?city:Hostile"),
+                                         "" /*unused, DS_CEASEFIRE */,
+                                         Q_("?city:Peaceful"),
+                                         Q_("?city:Friendly"),
+                                         Q_("?city:Mysterious")};
   out[0]='\0';
+  int turns;
 
 #ifdef DEBUG
-  my_snprintf(out, sizeof(out), _("Location: (%d, %d) [%d]\n"), 
+  my_snprintf(out, sizeof(out), _("Location: (%d, %d) [%d]"), 
              xtile, ytile, ptile->continent); 
 #endif /*DEBUG*/
   my_snprintf(buf, sizeof(buf), _("Terrain: %s"),
              map_get_tile_info_text(xtile, ytile));
-  sz_strlcat(out, buf);
-  my_snprintf(buf, sizeof(buf), _("\nFood/Prod/Trade: %s"),
+  add_line(out, buf);
+  my_snprintf(buf, sizeof(buf), _("Food/Prod/Trade: %s"),
              map_get_tile_fpt_text(xtile, ytile));
-  sz_strlcat(out, buf);
+  add_line(out, buf);
   if (tile_has_special(ptile, S_HUT)) {
-    sz_strlcat(out, _("\nMinor Tribe Village"));
+    add_line(out, _("Minor Tribe Village"));
   }
   if (game.borders > 0 && !pcity) {
     struct player *owner = map_get_owner(xtile, ytile);
     if (owner == game.player_ptr){
-      sz_strlcat(out, _("\nOur Territory"));
+      add_line(out, _("Our Territory"));
     } else if (owner) {
       if (game.player_ptr->diplstates[owner->player_no].type==DS_CEASEFIRE){
-       my_snprintf(buf, sizeof(buf), _("\n%s territory (%d turn ceasefire)"),
-                   get_nation_name(owner->nation),
-                   game.player_ptr->diplstates[owner->player_no].turns_left);
-      }else{
-       my_snprintf(buf, sizeof(buf), _("\nTerritory of the %s %s"),
-                   
diplo_adjectives[game.player_ptr->diplstates[owner->player_no].type],
+        turns = game.player_ptr->diplstates[owner->player_no].turns_left;
+       my_snprintf(buf, sizeof(buf), PL_("%s territory (%d turn ceasefire)",
+                                         "%s territory (%d turns ceasefire)",
+                                         turns),
+                   get_nation_name(owner->nation), turns);
+      } else {
+       my_snprintf(buf, sizeof(buf), _("Territory of the %s %s"),
+                   diplo_nation_plural_adjectives[game.player_ptr->
+                                           diplstates[owner->player_no].type],
                    get_nation_name_plural(owner->nation));
       }
-      sz_strlcat(out, buf);
+      add_line(out, buf);
     } else {
-      sz_strlcat(out, _("\nUnclaimed territory"));
+      add_line(out, _("Unclaimed territory"));
     }
   }
   if (pcity) {
@@ -303,30 +328,40 @@
     struct player *owner = city_owner(pcity);
 
     if (owner == game.player_ptr){
-      /* TRANS: "\nCity: <name> (<nation>)" */
-      my_snprintf(buf, sizeof(buf), _("\nCity: %s (%s)"), pcity->name,
+      /* TRANS: "City: <name> (<nation>)" */
+      my_snprintf(buf, sizeof(buf), _("City: %s (%s)"), pcity->name,
                  get_nation_name(owner->nation));
-      sz_strlcat(out, buf);
     } else if (owner) {
-      /* TRANS: "\nCity: <name> (<nation>,<diplomatic_state>)" */
-      my_snprintf(buf, sizeof(buf), _("\nCity: %s (%s,%s)"), pcity->name,
-                 get_nation_name(owner->nation),
-                 diplo_adjectives[game.player_ptr->
-                                  diplstates[owner->player_no].type]);
-      sz_strlcat(out, buf);
+      if (game.player_ptr->diplstates[owner->player_no].type==DS_CEASEFIRE) {
+        turns = game.player_ptr->diplstates[owner->player_no].turns_left;
+        my_snprintf(buf, sizeof(buf), PL_("City: %s (%s, %d turn ceasefire)",
+                                         "City: %s (%s, %d turns ceasefire)",
+                                         turns),
+                   get_nation_name(owner->nation),
+                   diplo_city_adjectives[game.player_ptr->
+                                         diplstates[owner->player_no].type],
+                   turns);
+      } else {
+        /* TRANS: "City: <name> (<nation>,<diplomatic_state>)" */
+        my_snprintf(buf, sizeof(buf), _("City: %s (%s,%s)"), pcity->name,
+                    get_nation_name(owner->nation),
+                   diplo_city_adjectives[game.player_ptr->
+                                         diplstates[owner->player_no].type]);
+      }
     }
     if (city_got_citywalls(pcity)) {
-      sz_strlcat(out, _(" with City Walls"));
+      sz_strlcat(buf, _(" with City Walls"));
     }
+    add_line(out, buf);
   } 
   if (get_tile_infrastructure_set(ptile)) {
-    my_snprintf(buf, sizeof(buf), _("\nInfrastructure: %s"),
+    my_snprintf(buf, sizeof(buf), _("Infrastructure: %s"),
                map_get_infrastructure_text(ptile->special));
-    sz_strlcat(out, buf);
+    add_line(out, buf);
   }
-  sz_strlcpy(buf, _("\nActivity: "));
+  sz_strlcpy(buf, _("Activity: "));
   if (concat_tile_activity_text(buf, sizeof(buf), xtile, ytile)) {
-    sz_strlcat(out, buf);
+    add_line(out, buf);
   }
   if (punit && !pcity) {
     char tmp[64] = {0};
@@ -337,9 +372,9 @@
        if (pcity)
          my_snprintf(tmp, sizeof(tmp), "/%s", pcity->name);
       }
-    my_snprintf(buf, sizeof(buf), _("\nUnit: %s(%s%s)"), ptype->name,
+    my_snprintf(buf, sizeof(buf), _("Unit: %s(%s%s)"), ptype->name,
                get_nation_name(unit_owner(punit)->nation), tmp);
-    sz_strlcat(out, buf);
+    add_line(out, buf);
     if (punit->owner != game.player_idx){
       struct unit *apunit;
       if ((apunit = get_unit_in_focus())) {
@@ -349,16 +384,16 @@
        /* chance to win when selected unit is attacking the active unit */
        int def_chance = (1.0 - unit_win_chance(punit, apunit)) * 100;
        
-       my_snprintf(buf, sizeof(buf), _("\nChance to win: A:%d%% D:%d%%"),
+       my_snprintf(buf, sizeof(buf), _("Chance to win: A:%d%% D:%d%%"),
                    att_chance, def_chance);
-       sz_strlcat(out, buf);
+       add_line(out, buf);
       }
     }
-    my_snprintf(buf, sizeof(buf), _("\nA:%d D:%d FP:%d HP:%d/%d%s"),
+    my_snprintf(buf, sizeof(buf), _("A:%d D:%d FP:%d HP:%d/%d%s"),
                    ptype->attack_strength, 
                    ptype->defense_strength, ptype->firepower, punit->hp, 
                    ptype->hp, punit->veteran ? _(" V") : "");
-    sz_strlcat(out, buf);
+    add_line(out, buf);
     if (punit->owner == game.player_idx && unit_list_size(&ptile->units) >= 2){
       my_snprintf(buf, sizeof(buf), _("  (%d more)"),
                  unit_list_size(&ptile->units) - 1);

[Prev in Thread] Current Thread [Next in Thread]