mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #24230 -- Added translated language name for i18n template tag/filter.
This commit is contained in:
committed by
Tim Graham
parent
9ca0961b8a
commit
002b3d87b5
@@ -342,17 +342,26 @@ class I18nTagTests(SimpleTestCase):
|
||||
)
|
||||
|
||||
@setup({'i18n32': '{% load i18n %}{{ "hu"|language_name }} '
|
||||
'{{ "hu"|language_name_local }} {{ "hu"|language_bidi }}'})
|
||||
'{{ "hu"|language_name_local }} {{ "hu"|language_bidi }} '
|
||||
'{{ "hu"|language_name_translated }}'})
|
||||
def test_i18n32(self):
|
||||
output = self.engine.render_to_string('i18n32')
|
||||
self.assertEqual(output, 'Hungarian Magyar False')
|
||||
self.assertEqual(output, 'Hungarian Magyar False Hungarian')
|
||||
|
||||
with translation.override('cs'):
|
||||
output = self.engine.render_to_string('i18n32')
|
||||
self.assertEqual(output, 'Hungarian Magyar False maďarsky')
|
||||
|
||||
@setup({'i18n33': '{% load i18n %}'
|
||||
'{{ langcode|language_name }} {{ langcode|language_name_local }} '
|
||||
'{{ langcode|language_bidi }}'})
|
||||
'{{ langcode|language_bidi }} {{ langcode|language_name_translated }}'})
|
||||
def test_i18n33(self):
|
||||
output = self.engine.render_to_string('i18n33', {'langcode': 'nl'})
|
||||
self.assertEqual(output, 'Dutch Nederlands False')
|
||||
self.assertEqual(output, 'Dutch Nederlands False Dutch')
|
||||
|
||||
with translation.override('cs'):
|
||||
output = self.engine.render_to_string('i18n33', {'langcode': 'nl'})
|
||||
self.assertEqual(output, 'Dutch Nederlands False nizozemsky')
|
||||
|
||||
# blocktrans handling of variables which are not in the context.
|
||||
# this should work as if blocktrans was not there (#19915)
|
||||
@@ -405,18 +414,26 @@ class I18nTagTests(SimpleTestCase):
|
||||
# Test whitespace in filter arguments
|
||||
@setup({'i18n38': '{% load i18n custom %}'
|
||||
'{% get_language_info for "de"|noop:"x y" as l %}'
|
||||
'{{ l.code }}: {{ l.name }}/{{ l.name_local }} bidi={{ l.bidi }}'})
|
||||
'{{ l.code }}: {{ l.name }}/{{ l.name_local }}/'
|
||||
'{{ l.name_translated }} bidi={{ l.bidi }}'})
|
||||
def test_i18n38(self):
|
||||
output = self.engine.render_to_string('i18n38')
|
||||
self.assertEqual(output, 'de: German/Deutsch bidi=False')
|
||||
with translation.override('cs'):
|
||||
output = self.engine.render_to_string('i18n38')
|
||||
self.assertEqual(output, 'de: German/Deutsch/německy bidi=False')
|
||||
|
||||
@setup({'i18n38_2': '{% load i18n custom %}'
|
||||
'{% get_language_info_list for langcodes|noop:"x y" as langs %}'
|
||||
'{% for l in langs %}{{ l.code }}: {{ l.name }}/'
|
||||
'{{ l.name_local }} bidi={{ l.bidi }}; {% endfor %}'})
|
||||
'{{ l.name_local }}/{{ l.name_translated }} '
|
||||
'bidi={{ l.bidi }}; {% endfor %}'})
|
||||
def test_i18n38_2(self):
|
||||
output = self.engine.render_to_string('i18n38_2', {'langcodes': ['it', 'no']})
|
||||
self.assertEqual(output, 'it: Italian/italiano bidi=False; no: Norwegian/norsk bidi=False; ')
|
||||
with translation.override('cs'):
|
||||
output = self.engine.render_to_string('i18n38_2', {'langcodes': ['it', 'fr']})
|
||||
self.assertEqual(
|
||||
output,
|
||||
'it: Italian/italiano/italsky bidi=False; '
|
||||
'fr: French/français/francouzsky bidi=False; '
|
||||
)
|
||||
|
||||
@setup({'template': '{% load i18n %}{% trans %}A}'})
|
||||
def test_syntax_error_no_arguments(self):
|
||||
|
||||
Reference in New Issue
Block a user