Mercurial > babel > mirror
comparison babel/messages/tests/frontend.py @ 600:e61e27d9347d trunk
"init" command support "--width" option (#284)
author | fschwarz |
---|---|
date | Mon, 20 Aug 2012 20:07:27 +0000 |
parents | 99c48a6ca1d6 |
children | 6dc7e067bafc |
comparison
equal
deleted
inserted
replaced
599:33c8c68b96c7 | 600:e61e27d9347d |
---|---|
563 """ % {'version': VERSION, | 563 """ % {'version': VERSION, |
564 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', | 564 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', |
565 tzinfo=LOCALTZ, locale='en_US'), | 565 tzinfo=LOCALTZ, locale='en_US'), |
566 'long_message': long_message}, | 566 'long_message': long_message}, |
567 open(po_file, 'U').read()) | 567 open(po_file, 'U').read()) |
568 | |
569 def test_supports_width(self): | |
570 self.cmd.input_file = 'project/i18n/long_messages.pot' | |
571 self.cmd.locale = 'en_US' | |
572 self.cmd.output_dir = 'project/i18n' | |
573 | |
574 long_message = '"'+ 'xxxxx '*15 + '"' | |
575 | |
576 pot_contents = open('project/i18n/messages.pot', 'U').read() | |
577 pot_with_very_long_line = pot_contents.replace('"bar"', long_message) | |
578 open(self.cmd.input_file, 'wb').write(pot_with_very_long_line) | |
579 self.cmd.width = 120 | |
580 self.cmd.finalize_options() | |
581 self.cmd.run() | |
582 | |
583 po_file = self._po_file('en_US') | |
584 assert os.path.isfile(po_file) | |
585 self.assertEqual( | |
586 r"""# English (United States) translations for TestProject. | |
587 # Copyright (C) 2007 FooBar, Inc. | |
588 # This file is distributed under the same license as the TestProject | |
589 # project. | |
590 # FIRST AUTHOR <EMAIL@ADDRESS>, 2007. | |
591 # | |
592 msgid "" | |
593 msgstr "" | |
594 "Project-Id-Version: TestProject 0.1\n" | |
595 "Report-Msgid-Bugs-To: bugs.address@email.tld\n" | |
596 "POT-Creation-Date: 2007-04-01 15:30+0200\n" | |
597 "PO-Revision-Date: %(date)s\n" | |
598 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | |
599 "Language-Team: en_US <LL@li.org>\n" | |
600 "Plural-Forms: nplurals=2; plural=(n != 1)\n" | |
601 "MIME-Version: 1.0\n" | |
602 "Content-Type: text/plain; charset=utf-8\n" | |
603 "Content-Transfer-Encoding: 8bit\n" | |
604 "Generated-By: Babel %(version)s\n" | |
605 | |
606 #. This will be a translator coment, | |
607 #. that will include several lines | |
608 #: project/file1.py:8 | |
609 msgid %(long_message)s | |
610 msgstr "" | |
611 | |
612 #: project/file2.py:9 | |
613 msgid "foobar" | |
614 msgid_plural "foobars" | |
615 msgstr[0] "" | |
616 msgstr[1] "" | |
617 | |
618 """ % {'version': VERSION, | |
619 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', | |
620 tzinfo=LOCALTZ, locale='en_US'), | |
621 'long_message': long_message}, | |
622 open(po_file, 'U').read()) | |
568 | 623 |
569 | 624 |
570 class CommandLineInterfaceTestCase(unittest.TestCase): | 625 class CommandLineInterfaceTestCase(unittest.TestCase): |
571 | 626 |
572 def setUp(self): | 627 def setUp(self): |