1#
2# Copyright 2007,2009,2011 Zuza Software Foundation
3#
4# This file is part of translate.
5#
6# translate 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# translate 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 Arabic language.
20
21.. seealso:: http://en.wikipedia.org/wiki/Arabic_language
22"""
23
24
25import re
26
27from translate.lang import common
28
29
30def reverse_quotes(text):
31    def convertquotation(match):
32        return "”%s“" % match.group(1)
33
34    return re.sub("“([^”]+)”", convertquotation, text)
35
36
37class ar(common.Common):
38    """This class represents Arabic."""
39
40    listseperator = "، "
41
42    puncdict = {
43        ",": "،",
44        ";": "؛",
45        "?": "؟",
46        # This causes problems with variables, so commented out for now:
47        # "%": "٪",
48    }
49
50    numbertuple = (
51        ("0", "٠"),  # U+0660 Arabic-Indic digit zero.
52        ("1", "١"),  # U+0661 Arabic-Indic digit one.
53        ("2", "٢"),  # U+0662 Arabic-Indic digit two.
54        ("3", "٣"),  # U+0663 Arabic-Indic digit three.
55        ("4", "٤"),  # U+0664 Arabic-Indic digit four.
56        ("5", "٥"),  # U+0665 Arabic-Indic digit five.
57        ("6", "٦"),  # U+0666 Arabic-Indic digit six.
58        ("7", "٧"),  # U+0667 Arabic-Indic digit seven.
59        ("8", "٨"),  # U+0668 Arabic-Indic digit eight.
60        ("9", "٩"),  # U+0669 Arabic-Indic digit nine.
61    )
62
63    ignoretests = {
64        "all": ["acronyms", "simplecaps", "startcaps"],
65    }
66
67    @classmethod
68    def punctranslate(cls, text):
69        text = super().punctranslate(text)
70        return reverse_quotes(text)
71