From: Bruno Haible Date: Mon, 17 Feb 2003 19:41:59 +0000 (+0000) Subject: Notes about KDE's context problem. X-Git-Tag: v0.12~259 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03ebbc02caf484a79d00b541b6c595cda4654198;p=thirdparty%2Fgettext.git Notes about KDE's context problem. --- diff --git a/Admin/kde-i18n b/Admin/kde-i18n new file mode 100644 index 000000000..c3306c08b --- /dev/null +++ b/Admin/kde-i18n @@ -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 + +--- 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);