Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi,

2011/6/15 Bjoern Michaelsen <bjoern.michaelsen@gmail.com>:
I would like to work on "gettextizaton" of LibreOffice. Michael said
you had an initial patch. Can you share it with me?

No, I have no patch, I just collected some starting points and design
considerations. You find those here:

http://wiki.documentfoundation.org/Development/gettext-design

I have an initial patch (attached) which works on Linux. There is
still a lot to implement, e.g. context handling, which also requires
re-design of the way we extract strings from the source etc. I just
wanted to let you know about my progress. Questions and comments are
welcome.

Also, can you let me know where the .xcd files are processed? IMHO not
all SDF translations pass the ResMgr in the library tl, only the
strings from .res files.

Thanks,
Andras
diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx
index f397532..a513e79 100644
--- a/tools/source/rc/resmgr.cxx
+++ b/tools/source/rc/resmgr.cxx
@@ -32,6 +32,8 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <libintl.h>
+#include <locale.h>
 #include <tools/debug.hxx>
 #include <tools/stream.hxx>
 #include <tools/resmgr.hxx>
@@ -1705,6 +1707,13 @@ ResMgr* ResMgr::CreateResMgr( const sal_Char* pPrefixName,
 
     OUString aPrefix( pPrefixName, strlen( pPrefixName ), osl_getThreadTextEncoding() );
 
+    setlocale(LC_ALL, "");
+    rtl::OUString aL10nPath(RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/program/resource"));
+    rtl::Bootstrap::expandMacros(aL10nPath);
+    char *p = bindtextdomain( pPrefixName, rtl::OUStringToOString(aL10nPath, 
RTL_TEXTENCODING_UTF8).getStr()+7);
+    OSL_TRACE( "bindtextdomain(): %s -> %s\n", pPrefixName, p );
+    textdomain( pPrefixName );
+
     if( ! aLocale.Language.getLength() )
         aLocale = ResMgrContainer::get().getDefLocale();
 
@@ -1783,9 +1792,15 @@ UniString ResMgr::ReadStringWithoutHook()
 
 UniString ResMgr::ReadString()
 {
+    UniString aEmptyStr;
     UniString aRet = ReadStringWithoutHook();
     if ( pImplResHookProc )
         pImplResHookProc( aRet );
+    if ( aRet != aEmptyStr )
+    {
+        char *p = gettext(rtl::OUStringToOString(aRet, RTL_TEXTENCODING_UTF8).getStr());
+        aRet = OUString(p, strlen(p), RTL_TEXTENCODING_UTF8);
+    }
     return aRet;
 }
 

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.