forked from gnome-keysign/babel-glade
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
BabelGladeExtractor.egg-info/ | ||
__pycache__/ | ||
test.appdata.xml | ||
test.desktop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
msgid "" | ||
msgstr "" | ||
"Language: fr\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
|
||
msgid "This should be translated." | ||
msgstr "Cela devrait être traduit." | ||
|
||
msgid "" | ||
"\n" | ||
" Multi line\n" | ||
" text.\n" | ||
" " | ||
msgstr "" | ||
"\n" | ||
" Texte\n" | ||
" multi-ligne.\n" | ||
" " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
msgid "" | ||
msgstr "" | ||
"Language: nl\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
|
||
msgid "This should be translated." | ||
msgstr "Dit moet worden vertaald." | ||
|
||
msgid "" | ||
"\n" | ||
" Multi line\n" | ||
" text.\n" | ||
" " | ||
msgstr "" | ||
"\n" | ||
" Meerregelige\n" | ||
" tekst.\n" | ||
" " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- Copyright 2019 Tobias Mueller <[email protected]> --> | ||
<component type="desktop"> | ||
<id>babelglade.test</id> | ||
|
||
<description> | ||
<p translatable="yes">This should be translated.</p> | ||
<p translatable="yes"> | ||
Multi line | ||
text. | ||
</p> | ||
</description> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Desktop Entry] | ||
Name=Keysign | ||
Comment=This should be translated. | ||
Keywords=python;gpg;gnupg;key;openpgp; | ||
Type=Application | ||
Exec=python3 -m keysign | ||
Icon=org.gnome.Keysign | ||
Categories=GTK;GNOME;Utility; | ||
StartupNotify=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
import os | ||
from babelglade.translate import translate_desktop_file, translate_appdata_file | ||
|
||
def relative(test_file): | ||
return os.path.join(os.path.dirname(__file__), test_file) | ||
|
||
|
||
def test_desktop_file(): | ||
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(): | ||
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 |