Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] (PR#18536) [Patch] Translatable unit class names
Home

[Freeciv-Dev] (PR#18536) [Patch] Translatable unit class names

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#18536) [Patch] Translatable unit class names
From: "Marko Lindqvist" <cazfi74@xxxxxxxxx>
Date: Wed, 12 Jul 2006 05:45:07 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=18536 >


  Eventually unit class names will be visible to end user. This patch 
makes them translatable.


  - ML


diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c   2006-07-12 15:31:45.515625000 +0300
+++ freeciv/client/packhand.c   2006-07-12 15:35:45.609375000 +0300
@@ -2133,7 +2133,8 @@
 
   c = unit_class_get_by_id(p->id);
 
-  sz_strlcpy(c->name, p->name);
+  sz_strlcpy(c->name_orig, p->name);
+  c->name        = Q_(c->name_orig); /* See translate_data_names */
   c->move_type   = p->move_type;
   c->hp_loss_pct = p->hp_loss_pct;
   c->flags       = p->flags;
diff -Nurd -X.diff_ignore freeciv/common/game.c freeciv/common/game.c
--- freeciv/common/game.c       2006-07-12 15:31:54.421875000 +0300
+++ freeciv/common/game.c       2006-07-12 15:35:45.687500000 +0300
@@ -594,6 +594,10 @@
     tthis->name = Q_(tthis->name_orig);
   } tech_type_iterate_end;
 
+  unit_class_iterate(tthis) {
+    tthis->name = Q_(tthis->name_orig);
+  } unit_class_iterate_end;
+
   unit_type_iterate(tthis) {
     tthis->name = Q_(tthis->name_orig);
   } unit_type_iterate_end;
diff -Nurd -X.diff_ignore freeciv/common/unittype.c freeciv/common/unittype.c
--- freeciv/common/unittype.c   2006-07-12 15:31:56.828125000 +0300
+++ freeciv/common/unittype.c   2006-07-12 15:35:45.734375000 +0300
@@ -372,7 +372,7 @@
   Unit_Class_id i;
 
   for (i = 0; i < UCL_LAST; i++) {
-    if (mystrcasecmp(unit_classes[i].name, s)==0) {
+    if (mystrcasecmp(unit_classes[i].name_orig, s)==0) {
       return &unit_classes[i];
     }
   }
diff -Nurd -X.diff_ignore freeciv/common/unittype.h freeciv/common/unittype.h
--- freeciv/common/unittype.h   2006-07-12 15:31:56.859375000 +0300
+++ freeciv/common/unittype.h   2006-07-12 15:35:45.781250000 +0300
@@ -37,7 +37,8 @@
 
 struct unit_class {
   Unit_Class_id id;
-  char name[MAX_LEN_NAME];
+  const char *name;        /* Translated name */
+  char name_orig[MAX_LEN_NAME];
   enum unit_move_type move_type;
   int hp_loss_pct;         /* Percentage of hitpoints lost each turn not in 
city or airbase */
   bv_unit_class_flags flags;
diff -Nurd -X.diff_ignore freeciv/data/civ1/units.ruleset 
freeciv/data/civ1/units.ruleset
--- freeciv/data/civ1/units.ruleset     2006-07-12 15:32:08.078125000 +0300
+++ freeciv/data/civ1/units.ruleset     2006-07-12 15:36:31.421875000 +0300
@@ -63,25 +63,25 @@
 ; "Missile"      = Unit is destroyed when it attacks
 
 [unitclass_land]
-name          = "Land"
+name          = _("Land")
 move_type     = "Land"
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows", "CanOccupy"
 
 [unitclass_sea]
-name          = "Sea"
+name          = _("Sea")
 move_type     = "Sea"
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows"
 
 [unitclass_air]
-name          = "Air"
+name          = _("Air")
 move_type     = "Air"
 hp_loss_pct   = 0
 flags         = ""
 
 [unitclass_missile]
-name          = "Missile"
+name          = _("Missile")
 move_type     = "Air"
 hp_loss_pct   = 0
 flags         = "Missile"
diff -Nurd -X.diff_ignore freeciv/data/civ2/units.ruleset 
freeciv/data/civ2/units.ruleset
--- freeciv/data/civ2/units.ruleset     2006-07-12 15:32:09.546875000 +0300
+++ freeciv/data/civ2/units.ruleset     2006-07-12 15:35:45.921875000 +0300
@@ -63,31 +63,31 @@
 ; "Missile"      = Unit is destroyed when it attacks
 
 [unitclass_missile]
-name          = "Missile"
+name          = _("Missile")
 move_type     = "Air"
 hp_loss_pct   = 0
 flags         = "Missile"
 
 [unitclass_land]
-name          = "Land"
+name          = _("Land")
 move_type     = "Land"
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows", "CanOccupy"
 
 [unitclass_sea]
-name          = "Sea"
+name          = _("Sea")
 move_type     = "Sea"
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows"
 
 [unitclass_heli]
-name          = "Helicopter"
+name          = _("Helicopter")
 move_type     = "Heli"
 hp_loss_pct   = 10
 flags         = "CanOccupy"
 
 [unitclass_air]
-name          = "Air"
+name          = _("Air")
 move_type     = "Air"
 hp_loss_pct   = 0
 flags         = ""
diff -Nurd -X.diff_ignore freeciv/data/default/units.ruleset 
freeciv/data/default/units.ruleset
--- freeciv/data/default/units.ruleset  2006-07-12 15:32:11.421875000 +0300
+++ freeciv/data/default/units.ruleset  2006-07-12 15:35:46.000000000 +0300
@@ -69,31 +69,31 @@
 ; "Missile"      = Unit is destroyed when it attacks
 
 [unitclass_missile]
-name          = "Missile"
+name          = _("Missile")
 move_type     = "Air"
 hp_loss_pct   = 0
 flags         = "Missile"
 
 [unitclass_land]
-name          = "Land"
+name          = _("Land")
 move_type     = "Land"
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows", "CanOccupy"
 
 [unitclass_sea]
-name          = "Sea"
+name          = _("Sea")
 move_type     = "Sea"
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows"
 
 [unitclass_heli]
-name          = "Helicopter"
+name          = _("Helicopter")
 move_type     = "Heli"
 hp_loss_pct   = 10
 flags         = "CanOccupy"
 
 [unitclass_air]
-name          = "Air"
+name          = _("Air")
 move_type     = "Air"
 hp_loss_pct   = 0
 flags         = ""
diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c    2006-07-12 15:34:48.078125000 +0300
+++ freeciv/server/ruleset.c    2006-07-12 15:35:46.125000000 +0300
@@ -874,7 +874,8 @@
     const int i = punitclass->id;
     char *name = secfile_lookup_str(file, "%s.name", sec[i]);
 
-    name_strlcpy(punitclass->name, name);
+    name_strlcpy(punitclass->name_orig, name);
+    punitclass->name = punitclass->name_orig;
   } unit_class_iterate_end;
 
   /* The names: */

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#18536) [Patch] Translatable unit class names, Marko Lindqvist <=