Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2006:
[Freeciv-Dev] (PR#14449) Citystyle names should use Q_() macro
Home

[Freeciv-Dev] (PR#14449) Citystyle names should use Q_() macro

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: evyscr@xxxxxxxxx, himasaram@xxxxxxxx
Subject: [Freeciv-Dev] (PR#14449) Citystyle names should use Q_() macro
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 9 Mar 2006 20:15:13 -0800
Reply-to: bugs@xxxxxxxxxxx

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

This patch should fix the problem, for city styles at least.

To summarize the ticket, the problem is that city styles use Q_ to be
translated; this is needed because "Asian" may be translated differently
if it's a city style versus a group.  However you can't change the city
style text to "?citystyle:Asian" in cities.ruleset because then you'd
have to change all the city style names in all the nations to match it.

The solution is just to fix the comparison in get_style_by_name so that
it skips the prefix.  This is done via a new macro, Qn_() ("Q"
nontranslated) which is just a wrapper for the prefix-skipping function.
 The patch implements Qn_() and uses it in get_style_by_name.  Just to
demonstrate, I also added a prefix to the Asian city style name.

It is possible/likely/certain that Qn_() will be needed in other places.
 Every string in translate_data_names is translated using Q_, but most
of these texts also have comparison functions (like get_tech_by_name). 
To actually be able to use the prefix, these comparison functions will
have to be changed to use Qn_.  This should be done on a case-by-case basis.

-jason

Index: utility/fcintl.h
===================================================================
--- utility/fcintl.h    (revision 11743)
+++ utility/fcintl.h    (working copy)
@@ -48,6 +48,11 @@
 
 #endif
 
+/* This provides an untranslated version of Q_ that allows the caller to
+ * get access to the original string.  This may be needed for comparisons,
+ * for instance. */
+#define Qn_(String) skip_intl_qualifier_prefix(String)
+
 const char *skip_intl_qualifier_prefix(const char *str);
 
 #endif  /* FC__FCINTL_H */
Index: data/default/cities.ruleset
===================================================================
--- data/default/cities.ruleset (revision 11743)
+++ data/default/cities.ruleset (working copy)
@@ -98,7 +98,7 @@
 replaced_by = "Renaissance"
 
 [citystyle_asian]
-name        = _("Asian")
+name        = _("?citystyle:Asian")
 graphic     = "city.asian"
 graphic_alt = "city.classical"
 citizens_graphic     = "ancient"
Index: common/city.c
===================================================================
--- common/city.c       (revision 11743)
+++ common/city.c       (working copy)
@@ -1106,7 +1106,9 @@
   int i;
 
   for (i = 0; i < game.control.styles_count; i++) {
-    if (strcmp(style_name, city_styles[i].name) == 0) {
+    /* City styles use Q_ so a city style may be called "?citystyle:Asian".
+     * We use Qn_ so that this string will match against "Asian". */
+    if (strcmp(Qn_(style_name), Qn_(city_styles[i].name)) == 0) {
       break;
     }
   }

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