You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by "D.J. Heap" <dj...@shadyvale.net> on 2004/04/09 01:34:17 UTC

[PATCH] gettext on Win32

This is not a complete patch, but I thought I'd put it out here for 
interested parties to look at and comment on.  It does not yet calculate 
the path to the locale directory, and it does not update the dsp 
generator -- just the vcproj one.  The changes are simple, though, and I 
can probably refactor some of it, once I update the dsp generator.

The locale project support is modelled after the existing neon.

I can compile and link and pass all tests with this, but I don't believe 
there is much really exercising the gettext stuff yet...once it goes in 
there may be more to be done, but shouldn't be much.

Any objections/recommendations on the approach?

Log:
Update the Win32 project generators to handle gettext and localization 
requirements.

* build.conf
   Add external-project path to locale target for Win32.

* build/win32/svn_locale.vcproj
   New project file for locale build target.

* build/generator/build_locale.ezt
   New batch file template for creating localization files.

* build/generator/gen_vcnet_vcproj.py
   Add support for the new TargetI18N target type.

* build/generator/gen_base.py
   (TargetI18N.__init__): Read in the external-project option.

* build/generator/gen_win.py
   Add --enable-nls option.  If it's on then populate the
   build_locale.bat file with the .po file targets and setup the
   appropriate defines and link settings.

* svn_private_config.hw
   Define N_, _, PACKAGE_NAME appropriately and stub in a
   SVN_LOCALE_DIR for now.

* gen-make.py
   Add Windows-specific --enable-nls option.


Re: [PATCH] gettext on Win32

Posted by "D.J. Heap" <dj...@shadyvale.net>.
Jostein Chr. Andersen wrote:
> On Monday 12 April 2004 07.02, Branko Čibej wrote:
> [...]
> 
>>Assuming Subversion binaries (and someday DLLs) are installed in 
>>$SVN_HOME\bin, I'd put the po files in $SVN_HOME\share\locale, then the 
>>path would be `dirname(GetModuleFileName(0))`/../share/locale.
>>
>>Then one day, when _all_ clients use the same core runtime instead of 
>>each installing its own... :-)
> 
> 
> +1
> 

Sounds good to me, too.  I'll save the ENABLE_NLS change for a later patch.

DJ


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] gettext on Win32

Posted by "Jostein Chr. Andersen" <jo...@josander.net>.
On Monday 12 April 2004 07.02, Branko Čibej wrote:
[...]
> Assuming Subversion binaries (and someday DLLs) are installed in 
> $SVN_HOME\bin, I'd put the po files in $SVN_HOME\share\locale, then the 
> path would be `dirname(GetModuleFileName(0))`/../share/locale.
> 
> Then one day, when _all_ clients use the same core runtime instead of 
> each installing its own... :-)

+1

-- 
http://www.josander.net/kontakt/ ||
http://www.josander.net/en/contact/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] gettext on Win32

Posted by "D.J. Heap" <dj...@shadyvale.net>.
Branko Čibej wrote:
> D.J. Heap wrote:
> 
>> @@ -123,6 +119,31 @@
>>       return EXIT_FAILURE;
>>     }
>>
>> +#ifdef ENABLE_NLS
>> +#ifdef WIN32
>> +  {
>> +    char native_file_name[_MAX_PATH];
>> +    const char* internal_path;
>> +    apr_pool_t* pool;
>> +    +    apr_pool_create (&pool, 0);
>> +    /* get exe name - our locale info will be in '../share/locale' */
>> +    GetModuleFileName (0, native_file_name, sizeof(native_file_name));
>> +    internal_path = svn_path_internal_style (native_file_name, pool);
>> +    /* get base path name */
>> +    internal_path = svn_path_dirname (internal_path, pool);
>> +    /* back up one dir and append 'share/locale' */
>> +    internal_path = svn_path_dirname (internal_path, pool);
>> +    internal_path = svn_path_join (internal_path, "share/locale", pool);
>> +    bindtextdomain (PACKAGE_NAME, internal_path);    +    
>> apr_pool_destroy (pool);
>>  
>>
> This will never work. Our internal path handling functions assume the 
> path name is in UTF-8, and gods only know what you get from the 
> GetModuleFileName. Look at how we do this in config_win.c: always use 
> the Unicode (UTF-16) versions of the functions, and use APR's converter 
> to change them to UTF-8. Also, I think we should skip the second 
> svn_path_dirname and just add "../share/locale", and make that a define. 
> svn_path_join (or svn_path_canonicalize) should learn to strip out the 
> ".."s anyway.

Ok, I'll do that today.

> 
> The rest seems O.K.
> 
> Now if only we could tell gettext to _not_ require libiconv.. Aargh!
> 

Yes, it does seem ridiculous to require two different conversion libraries.

DJ


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] gettext on Win32

Posted by Branko Čibej <br...@xbc.nu>.
D.J. Heap wrote:

>@@ -123,6 +119,31 @@
>       return EXIT_FAILURE;
>     }
> 
>+#ifdef ENABLE_NLS
>+#ifdef WIN32
>+  {
>+    char native_file_name[_MAX_PATH];
>+    const char* internal_path;
>+    apr_pool_t* pool;
>+    
>+    apr_pool_create (&pool, 0);
>+    /* get exe name - our locale info will be in '../share/locale' */
>+    GetModuleFileName (0, native_file_name, sizeof(native_file_name));
>+    internal_path = svn_path_internal_style (native_file_name, pool);
>+    /* get base path name */
>+    internal_path = svn_path_dirname (internal_path, pool);
>+    /* back up one dir and append 'share/locale' */
>+    internal_path = svn_path_dirname (internal_path, pool);
>+    internal_path = svn_path_join (internal_path, "share/locale", pool);
>+    bindtextdomain (PACKAGE_NAME, internal_path);    
>+    apr_pool_destroy (pool);
>  
>
This will never work. Our internal path handling functions assume the 
path name is in UTF-8, and gods only know what you get from the 
GetModuleFileName. Look at how we do this in config_win.c: always use 
the Unicode (UTF-16) versions of the functions, and use APR's converter 
to change them to UTF-8. Also, I think we should skip the second 
svn_path_dirname and just add "../share/locale", and make that a define. 
svn_path_join (or svn_path_canonicalize) should learn to strip out the 
".."s anyway.

The rest seems O.K.

Now if only we could tell gettext to _not_ require libiconv.. Aargh!

-- Brane

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] gettext on Win32

Posted by "D.J. Heap" <dj...@shadyvale.net>.
Here's a new version of the build system patch -- it builds and passes 
ra_local tests with and without gettext support.  It sounds like it'll 
need a slight tweak (for the direct gettext calls) and I need to change 
the dsp generator slightly, but I will do that and commit it tomorrow if 
there are no objections.  I have not actually tested trying to use an 
alternate language...if it's not very involved I will do it if told how 
(is it just a matter of temporarily changing Control Panel -> Regional 
and Language settings or do I need to install/change more stuff?).

I used the following gettext binaries from http://mirrors.kernel.org/gnu 
(I had c-runtime headaches trying to use the latest version and other 
implementations):

gettext-runtime-0.12.1.bin.woe32.zip
gettext-tools-0.12.1.bin.woe32.zip
libiconv-1.9.1.bin.woe32.zip

I will try to update the INSTALL doc sometime this weekend after this is 
committed.


Log:
Update the Win32 project generators to handle gettext and localization 
requirements.

* build.conf
   Add external-project path to locale target for Win32.

* build/win32/svn_locale.vcproj
   New project file for locale build target.

* build/generator/build_locale.ezt
   New batch file template for creating localization files.

* build/generator/gen_vcnet_vcproj.py
   Add support for the new TargetI18N target type.

* build/generator/gen_base.py
   (TargetI18N.__init__): Read in the external-project option.

* build/generator/gen_win.py
   Add --enable-nls option.  If it's on then populate the
   build_locale.bat file with the .po file targets and setup the
   appropriate defines and link settings.

* svn_private_config.hw
   Define N_, _, PACKAGE_NAME appropriately and stub in a
   SVN_LOCALE_DIR for now.

* gen-make.py
   Add Windows-specific --enable-nls option.

* subversion/libsvn_subr/cmdline.c
   (svn_cmdline_init): Setup gettext support for Win32 which involved
   moving the gettext initialization to after apr initialization so
   it's functionality could be used.


Re: [PATCH] gettext on Win32

Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
--On Monday, April 12, 2004 6:02 AM +0100 "Branko ?ibej" <br...@xbc.nu> wrote:

> I meant both Unix and Windows stuff, of course. I understand ENABLE_NLS is
> the "standard" define, but that doesn't mean it's right :-)

Agreed that it isn't brilliant, but I wouldn't change it.  -- justin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] gettext on Win32

Posted by Branko Čibej <br...@xbc.nu>.
D.J. Heap wrote:

> Branko Čibej wrote:
>
>> D.J. Heap wrote:
>
>>> @@ -453,6 +470,10 @@
>>>    if self.dblibname:
>>>      fakedefines.append("APU_HAVE_DB=1")
>>>
>>> +    # check if they wanted nls
>>> +    if self.enable_nls:
>>> +      fakedefines.append("ENABLE_NLS")
>>> +
>>>    return fakedefines
>>>
>>
>> Do we want to use "ENABLE_NLS" rather than "SVN_ENABLE_NLS"?
>
>
>
> I was trying to follow the unix stuff -- or do you mean change it just 
> in the Windows stuff and define ENABLE_NLS if SVN_ENABLE_NLS is defined?

I meant both Unix and Windows stuff, of course. I understand ENABLE_NLS 
is the "standard" define, but that doesn't mean it's right :-)

>>> ===================================================================
>>> --- svn_private_config.hw    (revision 9303)
>>> +++ svn_private_config.hw    (working copy)
>>> @@ -48,8 +48,16 @@
>>> /* Defined to be the path to the installed binaries */
>>> #define SVN_BINARY_DIR "/usr/local/bin"
>>>
>>> -/* Until Win32 gets gettext functionality, leave these disabled. */
>>> +/* Setup gettext macros */
>>> #define N_(x) (x)
>>> +#ifdef ENABLE_NLS
>>> +#define PACKAGE_NAME "subversion"
>>> +#define SVN_LOCALE_DIR "C:\\Stuff\\gettext\\share\\locale"
>>>
>>>
>> Index: svn_private_config.hw
>>
>> Ouch.
>> I know this is just a default (I expect you can override it in the
>> config file?), but even so...
>> Ah, the joys of Windows. :-)
>
>
>
>
> Yeah, I'll be addressing this somehow before committing -- you think a 
> config file option would be preferable to using a relative path based 
> on the (dynamically located with GetModuleFileName or something) path 
> to the gettext dll?  I'm not sure where exactly all that stuff needs 
> to go on Windows...

Putting Subversion's message files somewhere relative to the gettext DLL 
doesn't seem intuitive to me at all. Unlike on Unix, gettext doesn't 
have a well-known home on Windows, and sice Subversion already has its 
own dir structure there, it would be much more logical to put the po 
files there.

Assuming Subversion binaries (and someday DLLs) are installed in 
$SVN_HOME\bin, I'd put the po files in $SVN_HOME\share\locale, then the 
path would be `dirname(GetModuleFileName(0))`/../share/locale.

Then one day, when _all_ clients use the same core runtime instead of 
each installing its own... :-)

-- Brane

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] gettext on Win32

Posted by "D.J. Heap" <dj...@shadyvale.net>.
Branko Čibej wrote:

> D.J. Heap wrote:
> 
> 
>>Index: build.conf
>>===================================================================
>>--- build.conf	(revision 9303)
>>+++ build.conf	(working copy)
>>@@ -248,6 +248,7 @@
>>type = i18n
>>path = subversion/po
>>install = locale
>>+external-project = build/win32\svn_locale
>> 
>>
> 
> I think we should do away with backslashes as dir separators in
> build.conf...
> 


Good idea.


> 
>>@@ -453,6 +470,10 @@
>>    if self.dblibname:
>>      fakedefines.append("APU_HAVE_DB=1")
>>
>>+    # check if they wanted nls
>>+    if self.enable_nls:
>>+      fakedefines.append("ENABLE_NLS")
>>+
>>    return fakedefines
>> 
>>
> 
> Do we want to use "ENABLE_NLS" rather than "SVN_ENABLE_NLS"?


I was trying to follow the unix stuff -- or do you mean change it just 
in the Windows stuff and define ENABLE_NLS if SVN_ENABLE_NLS is defined?



> 
> 
>>Index: svn_private_config.hw
>>===================================================================
>>--- svn_private_config.hw	(revision 9303)
>>+++ svn_private_config.hw	(working copy)
>>@@ -48,8 +48,16 @@
>>/* Defined to be the path to the installed binaries */
>>#define SVN_BINARY_DIR "/usr/local/bin"
>>
>>-/* Until Win32 gets gettext functionality, leave these disabled. */
>>+/* Setup gettext macros */
>>#define N_(x) (x)
>>+#ifdef ENABLE_NLS
>>+#define PACKAGE_NAME "subversion"
>>+#define SVN_LOCALE_DIR "C:\\Stuff\\gettext\\share\\locale"
>> 
>>
> 
> Ouch.
> I know this is just a default (I expect you can override it in the
> config file?), but even so...
> Ah, the joys of Windows. :-)


Yeah, I'll be addressing this somehow before committing -- you think a 
config file option would be preferable to using a relative path based on 
the (dynamically located with GetModuleFileName or something) path to 
the gettext dll?  I'm not sure where exactly all that stuff needs to go 
on Windows...

DJ


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] gettext on Win32

Posted by Branko Čibej <br...@xbc.nu>.
D.J. Heap wrote:

>Index: build.conf
>===================================================================
>--- build.conf	(revision 9303)
>+++ build.conf	(working copy)
>@@ -248,6 +248,7 @@
> type = i18n
> path = subversion/po
> install = locale
>+external-project = build/win32\svn_locale
>  
>
I think we should do away with backslashes as dir separators in
build.conf...

>@@ -453,6 +470,10 @@
>     if self.dblibname:
>       fakedefines.append("APU_HAVE_DB=1")
> 
>+    # check if they wanted nls
>+    if self.enable_nls:
>+      fakedefines.append("ENABLE_NLS")
>+
>     return fakedefines
>  
>
Do we want to use "ENABLE_NLS" rather than "SVN_ENABLE_NLS"?

>Index: svn_private_config.hw
>===================================================================
>--- svn_private_config.hw	(revision 9303)
>+++ svn_private_config.hw	(working copy)
>@@ -48,8 +48,16 @@
> /* Defined to be the path to the installed binaries */
> #define SVN_BINARY_DIR "/usr/local/bin"
> 
>-/* Until Win32 gets gettext functionality, leave these disabled. */
>+/* Setup gettext macros */
> #define N_(x) (x)
>+#ifdef ENABLE_NLS
>+#define PACKAGE_NAME "subversion"
>+#define SVN_LOCALE_DIR "C:\\Stuff\\gettext\\share\\locale"
>  
>
Ouch.
I know this is just a default (I expect you can override it in the
config file?), but even so...
Ah, the joys of Windows. :-)

>+#include <locale.h>
>+#include <libintl.h>
>+#define _(x) dgettext(PACKAGE_NAME, x)
>+#else
> #define _(x) (x)
>+#endif
>  
>
Very nice, otherwise. :-)


-- 
Brane Čibej   <br...@xbc.nu>   http://www.xbc.nu/brane/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] gettext on Win32

Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
--On Thursday, April 8, 2004 7:34 PM -0600 "D.J. Heap" <dj...@shadyvale.net> 
wrote:

> I can compile and link and pass all tests with this, but I don't believe
> there is much really exercising the gettext stuff yet...once it goes in
> there may be more to be done, but shouldn't be much.

FWIW, the only thing using gettext right now is the default svn output:

% svn
Type 'svn help' for usage.
% LC_ALL=es_ES svn
Tipee 'svn help' para ver modo de uso.

Someone should go through Nicolás's last patch to add _() everywhere and 
commit it, but I'm totally short on time this week.  -- justin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org