File: test_translate.py

package info (click to toggle)
python-babelgladeextractor 0.7.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 156 kB
  • sloc: python: 248; xml: 101; makefile: 6
file content (42 lines) | stat: -rw-r--r-- 1,349 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

import os
import unittest
from babelglade.translate import translate_desktop_file, translate_appdata_file

def relative(test_file):
    return os.path.join(os.path.dirname(__file__), test_file)


class TranslateTestCase(unittest.TestCase):

    def test_desktop_file(self):
        translate_desktop_file(relative("test.raw.desktop"), "test.desktop", relative("locale"))

        with open("test.desktop") as desktop:
            content = desktop.read()

        assert "Comment=This should be translated." in content
        assert "Comment[nl]=Dit moet worden vertaald." in content
        assert "Comment[fr]=Cela devrait ĂȘtre traduit." in content

    def test_appdata_xml(self):
        translate_appdata_file(relative("test.raw.appdata.xml"), "test.appdata.xml", relative("locale"))

        with open("test.appdata.xml") as desktop:
            content = desktop.read()

        assert "<p>This should be translated.</p>" in content
        assert '<p xml:lang="fr">Cela devrait ĂȘtre traduit.</p>' in content
        assert '<p xml:lang="nl">Dit moet worden vertaald.</p>' in content
        assert """<p>
      Multi line
      text.
    </p>""" in content
        assert """<p xml:lang="fr">
      Texte
      multi-ligne.
    </p>""" in content
        assert """<p xml:lang="nl">
      Meerregelige
      tekst.
    </p>""" in content