1#
2# Copyright 2007, 2016 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 Khmer language.
20
21.. seealso:: http://en.wikipedia.org/wiki/Khmer_language
22"""
23
24
25import re
26
27from translate.lang import common
28
29
30class km(common.Common):
31    """This class represents Khmer."""
32
33    khmerpunc = "។៕៖៘"
34    """These marks are only used for Khmer."""
35
36    punctuation = "".join(
37        [
38            common.Common.commonpunc,
39            common.Common.quotes,
40            common.Common.miscpunc,
41            khmerpunc,
42        ]
43    )
44
45    sentenceend = "!?…។៕៘"
46
47    sentencere = re.compile(
48        r"""(?s)    #make . also match newlines
49                            .*?         #anything, but match non-greedy
50                            [%s]        #the puntuation for sentence ending
51                            \s+         #the spacing after the puntuation
52                            (?=[^a-z\d])#lookahead that next part starts with caps
53                            """
54        % sentenceend,
55        re.VERBOSE,
56    )
57    # \u00a0 is non-breaking space
58    puncdict = {
59        ".": "\u00a0។",
60        ":": "\u00a0៖",
61        "!": "\u00a0!",
62        "?": "\u00a0?",
63    }
64
65    ignoretests = {
66        "all": ["simplecaps", "startcaps"],
67    }
68
69    mozilla_nplurals = 2
70    mozilla_pluralequation = "n!=1 ? 1 : 0"
71