]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Notes about KDE's context problem.
authorBruno Haible <bruno@clisp.org>
Mon, 17 Feb 2003 19:41:59 +0000 (19:41 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:10:06 +0000 (12:10 +0200)
Admin/kde-i18n [new file with mode: 0644]

diff --git a/Admin/kde-i18n b/Admin/kde-i18n
new file mode 100644 (file)
index 0000000..c3306c0
--- /dev/null
@@ -0,0 +1,100 @@
+> But I agree with you that
+> 
+>        i18n("title in dialog","Check Equations")
+> 
+> would be prettier and easier to maintain, but needs some xgettext
+> support.
+Which we added with a little hack.
+
+# This is a patch for gettext-0.10.35 to allow translated messages
+# to have a context as used in Qt and KDE. 
+# (C) 2000 Stephan Kulow <coolo@kde.org>
+
+--- src/xgettext.c.orig        Sun May 14 18:16:25 2000
++++ src/xgettext.c     Sun May 14 18:27:20 2000
+@@ -835,7 +835,8 @@
+      int is_cpp_file;
+ {
+   int state;
+-
++  char *msgid = 0;
++  
+   /* Inform scanner whether we have C++ files or not.  */
+   if (is_cpp_file)
+     xgettext_lex_cplusplus ();
+@@ -861,8 +862,11 @@
+       State 3 = seen one of our keywords with string in second parameter
+       State 4 = was in state 3 and now saw a left paren
+       State 5 = waiting for comma after being in state 4
+-      State 6 = saw comma after being in state 5  */
++      State 6 = saw comma after being in state 5  
++      State 7 = after comma and State 2
++     */
+      xgettext_lex (&token);
++
+      switch (token.type)
+        {
+        case xgettext_token_type_keyword1:
+@@ -886,18 +890,51 @@
+            state = 0;
+          }
+        continue;
++       
++       case xgettext_token_type_rp:
++       if (state == 2) {
++         token.string = strdup(msgid);
++         remember_a_message (mlp, &token);
++         free(msgid);
++         msgid = 0;
++         state = 0;
++       }
++       continue;   
+        case xgettext_token_type_comma:
+-       state = state == 5 ? 6 : 0;
++       switch (state) {
++       case 5:
++         state = 6;
++         break;
++       case 2:
++         state = 7;
++         break;
++       default:
++         state = 0;
++         break;
++       }
+        continue;
+        case xgettext_token_type_string_literal:
+        if (extract_all || state == 2 || state == 6)
+          {
+-           remember_a_message (mlp, &token);
+-           state = 0;
++           if (msgid)
++             free(msgid);
++           msgid = strdup(token.string);
++           //      state = 0;
++         }
++       else if (state == 7) 
++         {
++           if (msgid) {
++             char *newstring = (char*)malloc(strlen(msgid) + strlen(token.string) + 20);
++             sprintf(newstring, "_: %s\n%s", msgid, token.string);
++             free(msgid);
++             free(token.string);
++             token.string = msgid = newstring;
++             state = 2;
++           }
+          }
+-       else
++       else 
+          {
+            free (token.string);
+            state = (state == 4 || state == 5) ? 5 : 0;
+
+
+Also need the corresponding two-argument gettext function in libgettext.h:
+gettext2(role,msg) :=
+  msgid := "_: " + role + "\n" + msg
+  trans := gettext(msgid)
+  return (trans == msgid ? msg : trans);