File: test_gui_translator.py

package info (click to toggle)
mnemosyne 2.7.3%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 9,804 kB
  • sloc: python: 34,077; ansic: 837; xml: 625; makefile: 249; sh: 63
file content (42 lines) | stat: -rwxr-xr-x 1,499 bytes parent folder | download | duplicates (2)
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
31
32
33
34
35
36
37
38
39
40
41
42
#
# test_gui_translator.py <Peter.Bienstman@UGent.be>
#


from mnemosyne_test import MnemosyneTest
from mnemosyne.libmnemosyne.gui_translator import GuiTranslator
from mnemosyne.libmnemosyne.gui_translators.no_gui_translator import NoGuiTranslator
from mnemosyne.libmnemosyne.gui_translator import iso6931_code_for_language_name
from mnemosyne.libmnemosyne.gui_translators.gettext_gui_translator import GetTextGuiTranslator

class TestGuiTranslator(MnemosyneTest):

    def test_gui_translator_2(self):
        self.mnemosyne.gui_translator()
        t = NoGuiTranslator(None)
        assert t("foo") == "foo"

    def test_gui_translator_3(self):
        card_type = self.card_type_with_id("1")
        assert card_type._()

    def test_fallback(self):
        from mnemosyne.libmnemosyne.gui_translator import _
        assert _("foo") == "foo"

    def test_gui_translation(self):
        from mnemosyne.libmnemosyne.gui_translator import _
        self.config()["ui_language"] = "de"
        self.mnemosyne.component_manager.current(
                "gui_translator").set_language("de")
        assert _("This is a test.") == "Dies ist ein Test."

    def test_1(self):
        t = GuiTranslator(self.mnemosyne.component_manager)
        assert t.supported_languages() == []
        assert iso6931_code_for_language_name("Zulu") == "zu"

        t = GetTextGuiTranslator(self.mnemosyne.component_manager)
        assert t.supported_languages() != []