My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Commit information:
~~~~~~~~~~~~~~~~~~~

Revision: 7789
http://translate.svn.sourceforge.net/translate/?rev=7789&view=rev
Author: friedelwolff
Date: 2008-07-17 14:21:32 +0000 (Thu, 17 Jul 2008)

Log Message:
-----------
Provide access to the libgettextpo version and use this to enable workarounds
for bugs related to notes in certain libgettextpo versions.

[Contributed by George Yoshikazu Kussumoto as part of GSoC2008]

Modified Paths:
--------------
src/trunk/translate/storage/cpo.py

Modified: src/trunk/translate/storage/cpo.py
===================================================================
--- src/trunk/translate/storage/cpo.py 2008-07-17 13:01:06 UTC (rev 7788)
+++ src/trunk/translate/storage/cpo.py 2008-07-17 14:21:32 UTC (rev 7789)
@@ -158,6 +158,20 @@
def encodingToUse(encoding):
return pypo.encodingToUse(encoding)

+def get_libgettextpo_version():
+ """Returns the libgettextpo version
+
+ @return: a three-value tuple containing the libgettextpo version in the
+ following format:
+ (major version, minor version, subminor version)
+ """
+ libversion = c_long.in_dll(gpo, 'libgettextpo_version')
+ major = libversion.value >> 16
+ minor = libversion.value >> 8
+ subminor = libversion.value - (major << 16) - (minor << 8)
+ return major, minor, subminor
+
+
class pounit(pocommon.pounit):
def __init__(self, source=None, encoding='utf-8', gpo_message=None):
self._encoding = encoding
@@ -309,8 +323,8 @@
comments = gpo.po_message_extracted_comments(self._gpo_message)
else:
raise ValueError("Comment type not valid")
- # FIXME this fixes a bug in Gettext that returns leading space with comments
- if comments:
+
+ if comments and get_libgettextpo_version() < (0, 17, 0):
comments = "\n".join([line.strip() for line in comments.split("\n")])
# Let's drop the last newline
return comments[:-1].decode(self._encoding)
@@ -338,11 +352,12 @@
newnotes = text + '\n' + oldnotes
else:
newnotes = "\n".join([line.rstrip() for line in text.split("\n")])
- # FIXME; workaround the need for leading spaces when adding comments to PO files in libgettexpo
+
if newnotes:
newlines = []
+ needs_space = get_libgettextpo_version() < (0, 17, 0)
for line in newnotes.split("\n"):
- if line:
+ if line and needs_space:
newlines.append(" " + line)
else:
newlines.append(line)
Show details Hide details

Change log

r41 by georgeyk.dev on Jul 20, 2008   Diff
# Update information about the patch
gsoc_libgettextpo_version_and_bugfix that
# was commited.
Go to: 

Older revisions

All revisions of this file

File info

Size: 2606 bytes, 70 lines
Hosted by Google Code