wrc: If the message context is 'do not translate', then don't add the string to the PO file.

Francois Gouget fgouget at free.fr
Wed Aug 24 07:40:53 CDT 2011


This makes it possible to ignore the RC file entries that don't need to be translated.
---

Our resource files contain some strings that I don't think can be 
translated in any meaningful way. For these my preferred action would 
be to remove them from the RC file. However for some I'm not sure that 
would make sense. For instance:

avifil32:      IDS_AVISTREAMFORMAT           "%s %s #%d"
msrle32:       IDS_NAME                      "WINE-MS-RLE"
msvidc32:      IDS_NAME                      "MS-CRAM"
notepad:       STRING_PAGESETUP_HEADERVALUE, "&f"
winefile:      IDS_TITLEFMT                  "%s - %s"
shdoclc:       IDS_PRINT_FOOTER_TEMPLATE     "&u&b&d"

If some of these can be removed from the RC file entirely I'll be happy 
to do so. But the goal of this patch is to deal with the remaining 
entries so that translators don't puzzle over what to do with them, or 
even worse translate them incorrectly (especially for format strings).

The patch is quite simple: if a string is tagged with the 'do not 
translate' message context it's simply not added to the PO file.

So for instance we could have:

        STRING_PAGESETUP_HEADERVALUE,   "#msgctxt#do not translate#&f"


 tools/wrc/po.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/tools/wrc/po.c b/tools/wrc/po.c
index 3efd208..1f69eeb 100644
--- a/tools/wrc/po.c
+++ b/tools/wrc/po.c
@@ -503,6 +503,7 @@ static po_file_t read_po_file( const char *name )
 static void add_po_string( po_file_t po, const string_t *msgid, const string_t *msgstr,
                            const language_t *lang )
 {
+    static const char* dnt = "do not translate";
     po_message_t msg;
     po_message_iterator_t iterator;
     int codepage;
@@ -512,6 +513,12 @@ static void add_po_string( po_file_t po, const string_t *msgid, const string_t *
 
     id_buffer = id = convert_msgid_ascii( msgid, 1 );
     context = get_message_context( &id );
+    if (context && strcmp(context, dnt) == 0)
+    {
+        /* This string should not be translated */
+        free( id_buffer );
+        return;
+    }
 
     if (msgstr)
     {
-- 
1.7.5.4



More information about the wine-patches mailing list