3 from translate
.convert
import prop2mozfunny
4 from translate
.misc
import wStringIO
7 def merge2inc(self
, incsource
, posource
):
8 """helper that merges po translations to .inc source without requiring files"""
9 inputfile
= wStringIO
.StringIO(posource
)
10 templatefile
= wStringIO
.StringIO(incsource
)
11 outputfile
= wStringIO
.StringIO()
12 result
= prop2mozfunny
.po2inc(inputfile
, outputfile
, templatefile
)
13 outputinc
= outputfile
.getvalue()
18 def test_no_endlines_added(self
):
19 """check that we don't add newlines at the end of file"""
20 posource
= '''# converted from #defines file\n#: MOZ_LANG_TITLE\nmsgid "English (US)"\nmsgstr "Deutsch (DE)"\n\n'''
21 inctemplate
= '''#define MOZ_LANG_TITLE Deutsch (DE)\n'''
22 incexpected
= inctemplate
23 incfile
= self
.merge2inc(inctemplate
, posource
)
25 assert incfile
== incexpected
27 def test_uncomment_contributors(self
):
28 """check that we handle uncommenting contributors properly"""
29 posource
= '''# converted from #defines file
30 #: MOZ_LANGPACK_CONTRIBUTORS
31 msgid "<em:contributor>Joe Solon</em:contributor>"
32 msgstr "<em:contributor>Mr Fury</em:contributor>"
34 inctemplate
= '''# #define MOZ_LANGPACK_CONTRIBUTORS <em:contributor>Joe Solon</em:contributor>\n'''
35 incexpected
= '''#define MOZ_LANGPACK_CONTRIBUTORS <em:contributor>Mr Fury</em:contributor>\n'''
36 incfile
= self
.merge2inc(inctemplate
, posource
)
38 assert incfile
== incexpected