1# 2# Copyright 2007-2017 Zuza Software Foundation 3# 4# This file is part of the Translate Toolkit. 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, see <http://www.gnu.org/licenses/>. 18 19"""This module represents the Romanian language. 20 21.. seealso:: http://en.wikipedia.org/wiki/Romanian_language 22""" 23 24 25from translate.filters.checks import FilterFailure, TranslationChecker 26from translate.filters.decorators import cosmetic 27from translate.lang import common 28 29 30def contains_illegal(illegal_substrings, string): 31 """Check if string contains any of the specified illegal substrings. 32 33 :param illegal_substrings: an iterable of illegal substrings 34 :param string: the string to check against occurences of illegal substrings 35 :return: True if string contains any of the illegal substrings 36 """ 37 for s in illegal_substrings: 38 if s in string: 39 return True 40 return False 41 42 43class RomanianChecker(TranslationChecker): 44 """A Checker class for Romanian""" 45 46 @cosmetic 47 def cedillas(self, str1, str2): 48 """Check if the translation contains an illegal cedilla character 49 50 Cedillas are obsoleted diacritics for Romanian: 51 52 - U+0162 Latin capital letter T with cedilla 53 - U+0163 Latin small letter T with cedilla 54 - U+015E Latin capital letter S with cedilla 55 - U+015F Latin small letter S with cedilla 56 57 Cedilla-letters are only valid for Turkish (S-cedilla) and Gagauz 58 languages (S-cedilla and T-comma). Fun fact: Gagauz is the only known 59 language to use T-cedilla. 60 61 :param str1: the source string 62 :param str2: the target (translated) string 63 :return: True if str2 contains a cedilla character 64 """ 65 if contains_illegal(["Ţ", "Ş", "ţ", "ş"], str2): 66 raise FilterFailure("String contains illegal cedillas") 67 return True 68 69 @cosmetic 70 def niciun_nicio(self, str1, str2): 71 """ 72 Checks for sequences containing 'nici un'/'nici o' which are obsolete 73 Romanian syntax. Correct is 'niciun'/'nicio' 74 """ 75 if contains_illegal(["nici un", "nici o"], str2): 76 raise FilterFailure("String contains 'nici un' or 'nici o'") 77 return True 78 79 80class ro(common.Common): 81 """This class represents Romanian""" 82 83 checker = RomanianChecker() 84