| Home | Trees | Indices | Help |
|
|---|
|
|
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 #
4 # Copyright 2007-2009 Zuza Software Foundation
5 #
6 # This file is part of the Translate Toolkit.
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, see <http://www.gnu.org/licenses/>.
20
21 """This module represents French language.
22
23 For more information, see U{http://en.wikipedia.org/wiki/French_language}
24 """
25
26 from translate.lang import common
27 import re
28
29
31
32 def convertquotation(match):
33 prefix = match.group(1)
34 # Let's see that we didn't perhaps match an XML tag property like
35 # <a href="something">
36 if prefix == u"=":
37 return match.group(0)
38 return u"%s«\u00a0%s\u00a0»" % (prefix, match.group(2)) #\u00a0 is NBSP
39
40 # Check that there is an even number of double quotes, otherwise it is
41 # probably not safe to convert them.
42 if text.count(u'"') % 2 == 0:
43 text = re.sub('(.|^)"([^"]+)"', convertquotation, text)
44 singlecount = text.count(u"'")
45 if singlecount:
46 if singlecount == text.count(u'`'):
47 text = re.sub("(.|^)`([^']+)'", convertquotation, text)
48 elif singlecount % 2 == 0:
49 text = re.sub("(.|^)'([^']+)'", convertquotation, text)
50 text = re.sub(u'(.|^)“([^”]+)”', convertquotation, text)
51 return text
52
53
55 """This class represents French."""
56
57 validaccel = u"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + \
58 u"1234567890" + \
59 u"éÉ"
60
61 # According to http://french.about.com/library/writing/bl-punctuation.htm,
62 # in French, a space is required both before and after all two- (or more)
63 # part punctuation marks and symbols, including : ; « » ! ? % $ # etc.
64 puncdict = {}
65 for c in u":;!?#":
66 puncdict[c] = u"\u00a0%s" % c
67 # TODO: consider adding % and $, but think about the consequences of how
68 # they could be part of variables
69
71 """Implement some extra features for quotation marks.
72
73 Known shortcomings:
74 - % and $ are not touched yet for fear of variables
75 - Double spaces might be introduced
76 """
77 text = super(cls, cls).punctranslate(text)
78 # We might get problems where we got a space in URIs such as
79 # http ://
80 text = text.replace(u"\u00a0://", "://")
81 return guillemets(text)
82 punctranslate = classmethod(punctranslate)
83
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Wed May 12 18:08:49 2010 | http://epydoc.sourceforge.net |