mirror of https://github.com/django/django.git
Added more tests for translation's to_locale().
This commit is contained in:
parent
22a5b8891c
commit
9829b75d5b
|
@ -259,8 +259,21 @@ class TranslationTests(SimpleTestCase):
|
|||
self.assertEqual('Catalan Win\nEOF\n', gettext('Win\r\nEOF\r\n'))
|
||||
|
||||
def test_to_locale(self):
|
||||
self.assertEqual(to_locale('en-us'), 'en_US')
|
||||
self.assertEqual(to_locale('sr-lat'), 'sr_Lat')
|
||||
tests = (
|
||||
('en', 'en'),
|
||||
('EN', 'en'),
|
||||
('en-us', 'en_US'),
|
||||
('EN-US', 'en_US'),
|
||||
# With > 2 characters after the dash.
|
||||
('sr-latn', 'sr_Latn'),
|
||||
('sr-LATN', 'sr_Latn'),
|
||||
# With private use subtag (x-informal).
|
||||
('sr-latn-x-informal', 'sr_Latn-x-informal'),
|
||||
('SR-LATN-X-INFORMAL', 'sr_Latn-x-informal'),
|
||||
)
|
||||
for lang, locale in tests:
|
||||
with self.subTest(lang=lang):
|
||||
self.assertEqual(to_locale(lang), locale)
|
||||
|
||||
def test_to_language(self):
|
||||
self.assertEqual(trans_real.to_language('en_US'), 'en-us')
|
||||
|
|
Loading…
Reference in New Issue