summaryrefslogtreecommitdiffstats
path: root/tests/unit/test-015-translate.py
blob: 5eaf5d122988dd8ed79bad7c8ce407d4f4ddf517 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-

import unittest
import gettext
from pykolab import translate

class TestTranslate(unittest.TestCase):

    def test_001_default_langs(self):
        self.assertTrue(len(translate.getDefaultLangs()) > 0)

    def test_002_translate(self):
        from pykolab.translate import _
        self.assertEqual(_("Folder name"), "Folder name")

    def test_003_set_lang(self):
        from pykolab.translate import _
        self.assertEqual(_("Folder name"), "Folder name")
        translate.setUserLanguage('de_DE')
        self.assertEqual(_("Folder name"), "Ordnername", "German Translation found")
        translate.setUserLanguage('foo_bar')
        self.assertEqual(_("Folder name"), "Folder name", "Unknown language falls back to NullTranslations")

    def test_004_unicode(self):
        from pykolab.translate import _
        translate.setUserLanguage('de_DE')
        self.assertEqual(_("recipients: %r"), "Empfänger: %r")

if __name__ == '__main__':
    unittest.main()