Skip to content

Commit 9aaccdc

Browse files
committed
Add test for spelling on source (id) messages
1 parent 5fafb71 commit 9aaccdc

3 files changed

Lines changed: 72 additions & 4 deletions

File tree

tests/fr_spelling_id.po

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#
2+
# Copyright (C) 2009-2014 Sébastien Helleu <flashcode@flashtux.org>
3+
#
4+
# This file is part of msgcheck.
5+
#
6+
# Msgcheck 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 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Msgcheck 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 msgcheck. If not, see <http://www.gnu.org/licenses/>.
18+
#
19+
20+
#
21+
# Gettext file with 2 spelling errors (in English source messages).
22+
#
23+
24+
msgid ""
25+
msgstr ""
26+
"Project-Id-Version: msgcheck\n"
27+
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
28+
"POT-Creation-Date: 2014-05-03 12:00+0200\n"
29+
"PO-Revision-Date: 2014-05-03 12:00+0200\n"
30+
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
31+
"Language-Team: flashcode@flashtux.org\n"
32+
"Language: fr\n"
33+
"MIME-Version: 1.0\n"
34+
"Content-Type: text/plain; charset=UTF-8\n"
35+
"Content-Transfer-Encoding: 8bit\n"
36+
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
37+
38+
msgid "Thsi is a test.\n"
39+
msgstr "Ceci est un test.\n"
40+
41+
msgid "Test 1"
42+
msgstr "Test 1"
43+
44+
msgid "Test 2"
45+
msgstr "Test 2"
46+
47+
#, c-format
48+
msgid " errro: %s"
49+
msgstr " erreur : %s"
50+
51+
#~ msgid "Obsolete message"
52+
#~ msgstr "Message obsolète"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919

2020
#
21-
# Gettext file with 2 spelling errors (in French).
21+
# Gettext file with 2 spelling errors (in French translations).
2222
#
2323

2424
msgid ""

tests/test_msgcheck.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,27 @@ def test_checks_fuzzy(self):
9595
# the file has 11 errors (with the fuzzy string)
9696
self.assertEquals(len(result[0][1]), 11)
9797

98-
def test_spelling(self):
99-
"""Test spelling on gettext files."""
98+
def test_spelling_id(self):
99+
"""Test spelling on source messages (English) of gettext files."""
100+
po_check = PoCheck()
101+
po_check.set_spelling_options('id', None, local_path('pwl.txt'))
102+
result = po_check.check_files([local_path('fr_spelling_id.po')])
103+
104+
# be sure we have 1 file in result
105+
self.assertEquals(len(result), 1)
106+
107+
# the file has 2 spelling errors: words "Thsi" and "errro"
108+
errors = result[0][1]
109+
self.assertEquals(len(errors), 2)
110+
for i, word in enumerate(('Thsi', 'errro')):
111+
self.assertEquals(errors[i].idmsg, 'spelling-id')
112+
self.assertEquals(errors[i].message, word)
113+
114+
def test_spelling_str(self):
115+
"""Test spelling on translated messages of gettext files."""
100116
po_check = PoCheck()
101117
po_check.set_spelling_options('str', None, local_path('pwl.txt'))
102-
result = po_check.check_files([local_path('fr_spelling.po'),
118+
result = po_check.check_files([local_path('fr_spelling_str.po'),
103119
local_path('fr_language.po')])
104120

105121
# be sure we have 2 files in result

0 commit comments

Comments
 (0)