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

Source Code for Module translate.lang.af

  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 Afrikaans language. 
 23   
 24  For more information, see U{http://en.wikipedia.org/wiki/Afrikaans_language} 
 25  """ 
 26   
 27  from translate.lang import common 
 28  import re 
 29   
 30  articlere = re.compile(r"'n\b") 
 31   
 32   
33 -class af(common.Common):
34 """This class represents Afrikaans.""" 35 36 punctuation = u"".join([common.Common.commonpunc, common.Common.quotes, 37 common.Common.miscpunc]) 38 sentenceend = u".!?…" 39 sentencere = re.compile(r"""(?s) #make . also match newlines 40 .*? #anything, but match non-greedy 41 [%s] #the puntuation for sentence ending 42 \s+ #the spacing after the puntuation 43 (?='n\s[A-Z]|[^'a-z\d]|'[^n]) 44 #lookahead that next part starts with caps or 'n followed by caps 45 """ % sentenceend, re.VERBOSE) 46
47 - def capsstart(cls, text):
48 """Modify this for the indefinite article ('n).""" 49 match = articlere.search(text, 0, 20) 50 if match: 51 #construct a list of non-apostrophe punctuation: 52 nonapos = u"".join(cls.punctuation.split(u"'")) 53 stripped = text.lstrip().lstrip(nonapos) 54 match = articlere.match(stripped) 55 if match: 56 return common.Common.capsstart(stripped[match.end():]) 57 return common.Common.capsstart(text)
58 capsstart = classmethod(capsstart)
59 60 cyr2lat = { 61 u"А": "A", u"а": "a", 62 u"Б": "B", u"б": "b", 63 u"В": "W", u"в": "w", # Different if at the end of a syllable see rule 2. 64 u"Г": "G", u"г": "g", # see rule 3 and 4 65 u"Д": "D", u"д": "d", 66 u"ДЖ": "Dj", u"дж": "dj", 67 u"Е": "Je", u"е": "je", # Sometimes e need to check when/why see rule 5. 68 u"Ё": "Jo", u"ё": "jo", # see rule 6 69 u"ЕЙ": "Ei", u"ей": "ei", 70 u"Ж": "Zj", u"ж": "zj", 71 u"З": "Z", u"з": "z", 72 u"И": "I", u"и": "i", 73 u"Й": "J", u"й": "j", # see rule 9 and 10 74 u"К": "K", u"к": "k", # see note 11 75 u"Л": "L", u"л": "l", 76 u"М": "M", u"м": "m", 77 u"Н": "N", u"н": "n", 78 u"О": "O", u"о": "o", 79 u"П": "P", u"п": "p", 80 u"Р": "R", u"р": "r", 81 u"С": "S", u"с": "s", # see note 12 82 u"Т": "T", u"т": "t", 83 u"У": "Oe", u"у": "oe", 84 u"Ф": "F", u"ф": "f", 85 u"Х": "Ch", u"х": "ch", # see rule 12 86 u"Ц": "Ts", u"ц": "ts", 87 u"Ч": "Tj", u"ч": "tj", 88 u"Ш": "Sj", u"ш": "sj", 89 u"Щ": "Sjtsj", u"щ": "sjtsj", 90 u"Ы": "I", u"ы": "i", # see note 13 91 u"Ъ": "", u"ъ": "", # See note 14 92 u"Ь": "", u"ь": "", # this letter is not in the AWS we assume it is left out as in the previous letter 93 u"Э": "E", u"э": "e", 94 u"Ю": "Joe", u"ю": "joe", 95 u"Я": "Ja", u"я": "ja", 96 } 97 """Mapping of Cyrillic to Latin letters for transliteration in Afrikaans""" 98 99 cyr_vowels = u"аеёиоуыэюя" 100 101
102 -def tranliterate_cyrillic(text):
103 """Convert Cyrillic text to Latin according to the AWS transliteration rules.""" 104 trans = u"" 105 for i in text: 106 trans += cyr2lat.get(i, i) 107 return trans
108