Greetings,
I submitted this patch a couple of years ago, but it didn't get much
attention. I still think it's relevant, so I'll try again.
[[[
On Windows, don't strip the Content-Type field from .po files during their
compilation.
GNU libintl, by default, converts the l10n strings into the locale
encoding, while Subversion requires UTF-8. This conversion can be
suppressed by calling bind_textdomain_codeset, but certain old versions of
libintl don't have that, so the Unix build system checks for the existence
of that function, and if it's not present, strips the Content-Type header
from the .po files (which prevents encoding conversion, as well, but makes
msgfmt complain).
When building on Windows, this stripping is done unconditionally, but is
completely unnecessary:
- On Windows, we only support linking with svn-win32-libintl, which is
hacked to disable all encoding conversions.
- Even if someone links with with his own version of libintl, it's a safe
bet that it will be new enough to support bind_textdomain_codeset, so we
can just call that.
This patch removes Content-Type stripping on Windows, which gets rid of
msgfmt warnings, as well as simplifies the build system.
* build/generator/build_locale.ezt: Remove the strip-po-charset.py
invocation.
* build/generator/gen_win.py:
(POFile.__init__): don't store the .spo file name.
* build/strip-po-charset.py: Delete.
* subversion/libsvn_subr/nls.c:
(svn_nls_init): Move the bind_textdomain_codeset call out of the
#ifdef WIN32 block, so it's executed on Windows, as well.
* subversion/svn_private_config.hw: Indicate that bind_textdomain_codeset
is available if NLS is enabled.
]]]
Roman.
Index: build/strip-po-charset.py
===================================================================
--- build/strip-po-charset.py (Revision 1369679)
+++ build/strip-po-charset.py (Arbeitskopie)
@@ -1,43 +0,0 @@
-#!/usr/bin/env python
-#
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-#
-#
-# strip-po-charset.py
-#
-
-import sys
-
-def strip_po_charset(inp, out):
-
- out.write(inp.read().replace("\"Content-Type: text/plain; charset=UTF-8\\n\"\n",""))
-
-def main():
-
- if len(sys.argv) != 3:
- print("Usage: %s <input (po) file> <output (spo) file>" % sys.argv[0])
- print("")
- print("Unsupported number of arguments; 2 required.")
- sys.exit(1)
-
- strip_po_charset(open(sys.argv[1],'r'), open(sys.argv[2],'w'))
-
-if __name__ == '__main__':
- main()
Index: build/generator/gen_win.py
===================================================================
--- build/generator/gen_win.py (Revision 1369679)
+++ build/generator/gen_win.py (Arbeitskopie)
@@ -1605,7 +1605,6 @@ class POFile:
"Item class for holding po file info"
def __init__(self, base):
self.po = base + '.po'
- self.spo = base + '.spo'
self.mo = base + '.mo'
# MSVC paths always use backslashes regardless of current platform
Index: build/generator/templates/build_locale.ezt
===================================================================
--- build/generator/templates/build_locale.ezt (Revision 1369686)
+++ build/generator/templates/build_locale.ezt (Arbeitskopie)
@@ -22,11 +22,8 @@ cd ..\..\..\subversion\po
mkdir ..\..\%1\mo
set exitcode=0
[for pofiles]echo Running msgfmt on [pofiles.po]...
-python ..\..\build\strip-po-charset.py [pofiles.po] [pofiles.spo]
+msgfmt.exe -c -o ..\..\%1\mo\[pofiles.mo] [pofiles.po]
if errorlevel 1 goto err
-msgfmt.exe -c -o ..\..\%1\mo\[pofiles.mo] [pofiles.spo]
-if errorlevel 1 goto err
-del [pofiles.spo]
[end]
goto end
@rem **************************************************************************
Index: subversion/libsvn_subr/nls.c
===================================================================
--- subversion/libsvn_subr/nls.c (Revision 1369679)
+++ subversion/libsvn_subr/nls.c (Arbeitskopie)
@@ -121,10 +121,12 @@ svn_nls_init(void)
#else /* ! WIN32 */
bindtextdomain(PACKAGE_NAME, SVN_LOCALE_DIR);
}
+#endif /* WIN32 */
+
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
bind_textdomain_codeset(PACKAGE_NAME, "UTF-8");
#endif /* HAVE_BIND_TEXTDOMAIN_CODESET */
-#endif /* WIN32 */
+
#endif /* ENABLE_NLS */
return err;
Index: subversion/svn_private_config.hw
===================================================================
--- subversion/svn_private_config.hw (Revision 1369679)
+++ subversion/svn_private_config.hw (Arbeitskopie)
@@ -84,6 +84,7 @@
#include <libintl.h>
#define _(x) dgettext(PACKAGE_NAME, x)
#define Q_(x1, x2, n) dngettext(PACKAGE_NAME, x1, x2, n)
+#define HAVE_BIND_TEXTDOMAIN_CODESET
#else
#define _(x) (x)
#define Q_(x1, x2, n) (((n) == 1) ? x1 : x2)
@@ -91,6 +92,7 @@
#define dgettext(domain, x) (x)
#endif
+
#endif /* SVN_PRIVATE_CONFIG_HW */
/* Inclusion of Berkeley DB header */