def test_export_handles_language_region_codes(self): # Fluent should handle 'en-US' as a language code. Previously # `export_translations_to_po('en-US')` would raise KeyError. MasterTranslation(text=u'Foo', hint=u'Bar', language_code='en').save() result = unicode(export_translations_to_po('en-US')) expected = ( u'Content-Type: text/plain\r\n' u'Content-Disposition: attachment; filename=django.po\r\n\r\n' u'#. Bar\n' u'msgctxt "Bar"\n' u'msgid "Foo"\n' u'msgstr "Foo"\n' ) self.assertEqual(result, expected)
def test_export(self): MasterTranslation( text=u"Wave", hint="Hand gesture", language_code="en").save() MasterTranslation( text=u"Wave", hint="Oceanic", language_code="en").save() MasterTranslation( text="One message removed", hint="Message(s) removed plural", plural_text="%d messages deleted", language_code="en").save() MasterTranslation( text=u"Something to translate", language_code="en").save() MasterTranslation( text=u"Product®™ — Special chars", language_code="en").save() po_file = polib.pofile(unicode( export_translations_to_po('en').content.decode('utf-8'))) self.assertEqual(EXPECTED_EXPORT_PO_FILE, po_file.__unicode__())