Example #1
0
    def test_lazy(self):
        bundle = Bundle(['tests/main.ftl'], default_locale='en')

        l = bundle.format_lazy('simple')
        self.assertEqual(force_text(l), 'Simple')
        activate('fr-FR')
        self.assertEqual(force_text(l), 'Facile')
        deactivate()
        self.assertEqual(force_text(l), 'Simple')
Example #2
0
    def test_lazy_with_require_activate(self):
        bundle = Bundle(['tests/main.ftl'],
                        default_locale='en',
                        require_activate=True)
        self.assertRaises(NoLocaleSet, bundle.format, 'simple')
        msg = bundle.format_lazy('simple')

        self.assertRaises(NoLocaleSet, force_text, msg)

        activate('en')
        self.assertEqual(force_text(msg), 'Simple')
        activate('fr-FR')
        self.assertEqual(force_text(msg), 'Facile')