Package translate :: Package lang :: Module fr
[hide private]
[frames] | no frames]

Source Code for Module translate.lang.fr

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3  #  
 4  # Copyright 2007 Zuza Software Foundation 
 5  #  
 6  # This file is part of translate. 
 7  # 
 8  # translate 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  # translate 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 translate; if not, write to the Free Software 
20  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
21   
22  """This module represents French language. 
23   
24  For more information, see U{http://en.wikipedia.org/wiki/French_language} 
25  """ 
26   
27  from translate.lang import common 
28  import re 
29   
30 -class fr(common.Common):
31 """This class represents French.""" 32 code = "fr" 33 fullname = "French" 34 nplurals = 2 35 pluralequation = "(n > 1)" 36 37 # According to http://french.about.com/library/writing/bl-punctuation.htm, 38 # in French, a space is required both before and after all two- (or more) 39 # part punctuation marks and symbols, including : ; « » ! ? % $ # etc. 40 puncdict = {} 41 for c in u":;!?#": 42 puncdict[c] = u" %s" % c 43 # TODO: consider adding % and $, but think about the consequences of how 44 # they could be part of variables 45
46 - def punctranslate(cls, text):
47 """Implement some extra features for quotation marks. 48 49 Known shortcomings: 50 - % and $ are not touched yet for fear of variables 51 - Double spaces might be introduced 52 """ 53 text = super(cls, cls).punctranslate(text) 54 55 def convertquotation(match): 56 prefix = match.group(1) 57 # Let's see that we didn't perhaps match an XML tag property like 58 # <a href="something"> 59 if prefix == u"=": 60 return match.group(0) 61 return u"%s« %s »" % (prefix, match.group(2))
62 63 # Check that there is an even number of double quotes, otherwise it is 64 # probably not safe to convert them. 65 if text.count(u'"') % 2 == 0: 66 text = re.sub('(.|^)"([^"]+)"', convertquotation, text) 67 68 return text
69 punctranslate = classmethod(punctranslate) 70