Complete.Org: Mailing Lists: Archives: freeciv-i18n: January 2003:
[freeciv-i18n] [rt@xxxxxxxxxxxxxx: [Freeciv-Dev] (PR#2403)]
Home

[freeciv-i18n] [rt@xxxxxxxxxxxxxx: [Freeciv-Dev] (PR#2403)]

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv I18n <freeciv-i18n@xxxxxxxxxxx>
Subject: [freeciv-i18n] [rt@xxxxxxxxxxxxxx: [Freeciv-Dev] (PR#2403)]
From: Christian Knoke <chrisk@xxxxxxxx>
Date: Mon, 13 Jan 2003 11:25:02 +0100

----- Forwarded message from Vasco Alexandre Da Silva Costa via RT 
<rt@xxxxxxxxxxxxxx> -----

From: "Vasco Alexandre Da Silva Costa via RT" <rt@xxxxxxxxxxxxxx>
Date: Sun, 12 Jan 2003 15:24:42 -0800
To: juhani.heino@xxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#2403)



This patch fixes the bug by making translate_menu_path break strings
appropriately. I'll apply it to CVS.

This means you translators can now translate like this:

#: client/gui-gtk-2.0/menu.c:704
msgid "Diplomat\\/Spy Actions"
msgstr "Aktionen von Diplomaten\\/Spionen"

And it will work.

---
Vasco Alexandre da Silva Costa @ Instituto Superior Tecnico, Lisboa


Content-Description: menu.diff
--- client/gui-gtk-2.0/menu.c   1 Jan 2003 11:51:33 -0000       1.10
+++ client/gui-gtk-2.0/menu.c   12 Jan 2003 23:19:21 -0000
@@ -795,6 +795,31 @@
 
   Path should include underscores like in the menu itself.
 *****************************************************************/
+static char *menu_path_tok(char *path)
+{
+  bool escaped = FALSE;
+
+  while (*path) {
+    if (escaped) {
+      escaped = FALSE;
+    } else {
+      if (*path == '\\') {
+        escaped = TRUE;
+      } else if (*path == '/') {
+        *path = '\0';
+        return path;
+      }
+    }
+
+    path++;
+  }
+
+  return NULL;
+}
+
+/****************************************************************
+...
+*****************************************************************/
 static const char *translate_menu_path(const char *path, int remove_uline)
 {
 #ifndef ENABLE_NLS
@@ -802,22 +827,24 @@
   strcpy(res, path);
 #else
   static struct astring in, out, tmp;   /* these are never free'd */
-  char *tok, *s, *trn, *t;
+  char *tok, *next, *trn, *t;
   int len;
   char *res;
 
-  /* copy to in so can modify with strtok: */
+  /* copy to in so can modify with menu_path_tok: */
   astr_minsize(&in, strlen(path)+1);
   strcpy(in.str, path);
   astr_minsize(&out, 1);
   out.str[0] = '\0';
   freelog(LOG_DEBUG, "trans: %s", in.str);
 
-  s = in.str;
-  while ((tok=strtok(s, "/"))) {
+  tok = in.str;
+  do {
+    next = menu_path_tok(tok);
+
     len = strlen(tok);
     freelog(LOG_DEBUG, "tok \"%s\", len %d", tok, len);
-    if (len && tok[0] == '<' && tok[len-1] == '>') {
+    if (len == 0 || (tok[0] == '<' && tok[len-1] == '>')) {
       t = tok;
     } else {
       trn = _(tok);
@@ -830,8 +857,8 @@
     astr_minsize(&out, out.n + len);
     strcat(out.str, t);
     freelog(LOG_DEBUG, "t \"%s\", len %d, out \"%s\"", t, len, out.str);
-    s = NULL;
-  }
+    tok = next+1;
+  } while (next);
   res = out.str;
 #endif
 


----- End forwarded message -----

-- 
Christian Knoke     * * *      http://www.enter.de/~c.knoke/
* * * * * * * * *  Ceterum censeo Microsoft esse dividendum.


[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-i18n] [rt@xxxxxxxxxxxxxx: [Freeciv-Dev] (PR#2403)], Christian Knoke <=