Skip to content

Commit 773bd14

Browse files
Add reflang longer than 2 characters test case.
1 parent 7e79a77 commit 773bd14

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
474 Bytes
Binary file not shown.
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SOME DESCRIPTIVE TITLE.
2+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3+
# This file is distributed under the same license as the PACKAGE package.
4+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5+
#
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: Rosetta\n"
9+
"Report-Msgid-Bugs-To: \n"
10+
"POT-Creation-Date: 2014-02-28 13:36+0100\n"
11+
"PO-Revision-Date: 2008-09-22 11:02\n"
12+
"Last-Translator: Admin Admin <admin@admin.com>\n"
13+
"Language-Team: xx_XX <LL@li.org>\n"
14+
"Language: xx_XX\n"
15+
"MIME-Version: 1.0\n"
16+
"Content-Type: text/plain; charset=UTF-8\n"
17+
"Content-Transfer-Encoding: 8bit\n"
18+
"X-Translated-Using: django-rosetta 0.4.RC2\n"
19+
20+
msgid "String 1"
21+
msgstr ""
22+
23+
msgid "String 2"
24+
msgstr ""
25+
26+
#. Translators: This is a text of the base template
27+
#: templates/base.html:43
28+
msgid "String 3 with comment"
29+
msgstr ""
30+
31+
msgctxt "Context hint"
32+
msgid "String 4"
33+
msgstr ""

rosetta/tests/tests.py

+23
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ def xx_form_url(self):
7070
kwargs = {"po_filter": "third-party", "lang_id": "xx", "idx": 0}
7171
return reverse("rosetta-form", kwargs=kwargs)
7272

73+
@property
74+
def xx_XX_form_url(self):
75+
kwargs = {"po_filter": "third-party", "lang_id": "xx_XX", "idx": 0}
76+
return reverse("rosetta-form", kwargs=kwargs)
77+
7378
@property
7479
def all_file_list_url(self):
7580
return reverse("rosetta-file-list", kwargs={"po_filter": "all"})
@@ -670,6 +675,24 @@ def test_33_reflang(self):
670675
'<span class="message">translated-string1</span>' in r.content.decode()
671676
)
672677

678+
@override_settings(
679+
ROSETTA_ENABLE_REFLANG=True, ROSETTA_LANGUAGES=(("xx", "xx dummy language"), ("xx_XX", "xx_XX dummy language"), )
680+
)
681+
def test_34_reflang_longer_2_characters(self):
682+
self.copy_po_file_from_template("./django.po.issue60.template")
683+
r = self.client.get(self.xx_XX_form_url)
684+
685+
# Verify that there's an option to select a reflang
686+
self.assertTrue(
687+
'<option value="?ref_lang=xx_XX">xx_XX dummy language</option>' in r.content.decode()
688+
)
689+
690+
r = self.client.get(self.xx_XX_form_url + "?ref_lang=xx")
691+
# The translated string in the test PO file ends up in the "Reference" column
692+
self.assertTrue(
693+
'<span class="message">translated-string1</span>' in r.content.decode()
694+
)
695+
673696
def test_show_occurrences(self):
674697
r = self.client.get(self.xx_form_url)
675698
# Verify that occurrences in view

0 commit comments

Comments
 (0)