Permalink
Browse files

Refactored the Javascript testing to automatic testing, added new tes…

…ts for changed order with plural and placeholder
  • Loading branch information...
Getty committed Jan 6, 2013
1 parent 7e1b10c commit df5f8de3a1c268ff5e9c40f22d3ba49d5fb5eb29
View
@@ -59,6 +59,16 @@ def translate():
'Du hast 4 Nachrichten von harry'
)
+ testeq(
+ ln('%2$s brought %1$d message','%2$s brought %1$d messages',1,'harry'),
+ '1 Nachricht gebracht von harry'
+ )
+
+ testeq(
+ ln('%2$s has %1$d message','%2$s has %1$d messages',4,'harry'),
+ 'harry hat 4 Nachrichten'
+ )
+
testeq(
l("Change order test %s %s", 'one', 'two'),
"Andere Reihenfolge hier two one"
View
@@ -14,51 +14,63 @@ ltd('test');
l_lang('de_DE');
is(
- l("Hello"),
- "Hallo",
- "simple"
+ l('Hello'),
+ 'Hallo',
+ 'simple'
);
is(
- ln("You have %d message","You have %d messages",4),
+ ln('You have %d message','You have %d messages',4),
'Du hast 4 Nachrichten',
- "simple plural test with plural"
+ 'plural test with plural'
);
is(
- ln("You have %d message","You have %d messages",1),
+ ln('You have %d message','You have %d messages',1),
'Du hast 1 Nachricht',
- "simple plural test with single"
+ 'plural test with single'
);
is(
- ln("You have %d message of %s","You have %d messages of %s",1,'harry'),
+ ln('You have %d message of %s','You have %d messages of %s',1,'harry'),
'Du hast 1 Nachricht von harry',
- "complex plural test with single"
+ 'plural test with single and additional placeholder'
);
is(
- ln("You have %d message of %s","You have %d messages of %s",4,'harry'),
+ ln('You have %d message of %s','You have %d messages of %s',4,'harry'),
'Du hast 4 Nachrichten von harry',
- "complex plural test with plural"
+ 'plural test with plural and additional placeholder'
);
is(
- l("Change order test %s %s",1,2),
+ ln('%2$s brought %1$d message','%2$s brought %1$d messages',1,'harry'),
+ '1 Nachricht gebracht von harry',
+ 'changed order plural test with single and additional placeholder'
+);
+
+is(
+ ln('%2$s has %1$d message','%2$s has %1$d messages',4,'harry'),
+ 'harry hat 4 Nachrichten',
+ 'other changed order plural test with plural and additional placeholder'
+);
+
+is(
+ l('Change order test %s %s',1,2),
'Andere Reihenfolge hier 2 1',
- "changing position test"
+ 'changing position test'
);
is(
- l("Other change order test %s %s %s",1,2,3),
+ l('Other change order test %s %s %s',1,2,3),
'Verhalten aus http://perldoc.perl.org/functions/sprintf.html 3 1 1',
- "other changing position test"
+ 'other changing position test'
);
is(
- lp("alien","Hello"),
- "Hallo Ausserirdischer",
- "simple test with context"
+ lp('alien','Hello'),
+ 'Hallo Ausserirdischer',
+ 'simple test with context'
);
done_testing;
@@ -1 +1 @@
-locale_data['test'] = {"":{"Plural-Forms":" nplurals=2; plural=n != 1;","MIME-Version":" 1.0","POT-Creation-Date":" 2009-06-14 09:29-0400","Language":" de_DE","Last-Translator":" Community","Content-Type":" text/plain; charset=UTF-8","Language-Team":" DuckDuckGo Community <community@duckduckgo.com>","PO-Revision-Date":" 2009-06-14 09:29-0400","Content-Transfer-Encoding":" 8bit","Project-Id-Version":" DuckDuckGo-Translation-0.000"},"alien\u0004Hello":[null,"Hallo Ausserirdischer"],"Hello":[null,"Hallo"],"Change order test %s %s":[null,"Andere Reihenfolge hier %2$s %1$s"],"You have %d message of %s":["You have %d messages of %s","Du hast %d Nachricht von %s","Du hast %d Nachrichten von %s"],"You have %d message":["You have %d messages","Du hast %d Nachricht","Du hast %d Nachrichten"],"Other change order test %s %s %s":[null,"Verhalten aus http://perldoc.perl.org/functions/sprintf.html %3$s %s %1$s"]};
+locale_data['test'] = {"":{"Plural-Forms":" nplurals=2; plural=n != 1;","MIME-Version":" 1.0","POT-Creation-Date":" 2009-06-14 09:29-0400","Language":" de_DE","Last-Translator":" Community","Content-Type":" text/plain; charset=UTF-8","Language-Team":" DuckDuckGo Community <community@duckduckgo.com>","PO-Revision-Date":" 2009-06-14 09:29-0400","Content-Transfer-Encoding":" 8bit","Project-Id-Version":" DuckDuckGo-Translation-0.000"},"alien\u0004Hello":[null,"Hallo Ausserirdischer"],"Hello":[null,"Hallo"],"Change order test %s %s":[null,"Andere Reihenfolge hier %2$s %1$s"],"%2$s has %1$d message":["%2$s has %1$d messages","%2$s hat %1$d Nachricht","%2$s hat %1$d Nachrichten"],"%2$s brought %1$d message":["%2$s brought %1$d messages","%d Nachricht gebracht von %s","%d Nachrichten gebracht von %s"],"You have %d message of %s":["You have %d messages of %s","Du hast %d Nachricht von %s","Du hast %d Nachrichten von %s"],"You have %d message":["You have %d messages","Du hast %d Nachricht","Du hast %d Nachrichten"],"Other change order test %s %s %s":[null,"Verhalten aus http://perldoc.perl.org/functions/sprintf.html %3$s %s %1$s"]};
Binary file not shown.
@@ -21,6 +21,16 @@ msgid_plural "You have %d messages of %s"
msgstr[0] "Du hast %d Nachricht von %s"
msgstr[1] "Du hast %d Nachrichten von %s"
+msgid "%2$s brought %1$d message"
+msgid_plural "%2$s brought %1$d messages"
+msgstr[0] "%d Nachricht gebracht von %s"
+msgstr[1] "%d Nachrichten gebracht von %s"
+
+msgid "%2$s has %1$d message"
+msgid_plural "%2$s has %1$d messages"
+msgstr[0] "%2$s hat %1$d Nachricht"
+msgstr[1] "%2$s hat %1$d Nachrichten"
+
msgid "Hello"
msgstr "Hallo"
@@ -7,33 +7,49 @@
<script language="javascript" src="locale/de_DE/LC_MESSAGES/othertest.json"></script>
<script language="javascript">
- function add_t(text) {
+ function tt(text,result) {
var newdiv = document.createElement('div');
var tn = document.createTextNode(text);
newdiv.appendChild(tn);
document.getElementById("t").appendChild(newdiv);
+ if (result == text) {
+ newdiv.style.color = 'green';
+ } else {
+ newdiv.style.color = 'red';
+ var failtext = document.createTextNode(
+ 'Test failed! Correct would be: "' + result + '"'
+ );
+ var failtextdiv = document.createElement('div');
+ var failtext = document.createTextNode(
+ 'Test failed! Correct would be: "' + result + '"'
+ );
+ failtextdiv.style.color = 'red';
+ failtextdiv.appendChild(failtext);
+ document.getElementById("t").appendChild(failtextdiv);
+ var faildiv = document.getElementById('fail');
+ faildiv.style.display = 'block';
+ }
}
window.onload = function() {
ltd('test');
- add_t(l("Hello"));
- add_t('Should be: "' + 'Hallo' + '"');
- add_t(ln("You have %d message","You have %d messages",4));
- add_t('Should be: "' + 'Du hast 4 Nachrichten' + '"');
- add_t(ln("You have %d message","You have %d messages",1));
- add_t('Should be: "' + 'Du hast 1 Nachricht' + '"');
- add_t(ln("You have %d message of %s","You have %d messages of %s",4,'harry'));
- add_t('Should be: "' + 'Du hast 4 Nachrichten von harry' + '"');
- add_t(ln("You have %d message of %s","You have %d messages of %s",1,'harry'));
- add_t('Should be: "' + 'Du hast 1 Nachricht von harry' + '"');
- add_t(l("Change order test %s %s",1,2));
- add_t('Should be: "' + 'Andere Reihenfolge hier 2 1' + '"');
- add_t(l("Other change order test %s %s %s",1,2,3));
- add_t('Should be: "' + 'Verhalten aus http://perldoc.perl.org/functions/sprintf.html 3 1 1' + '"');
- add_t(lp("alien","Hello"));
- add_t('Should be: "' + 'Hallo Ausserirdischer' + '"');
+ tt(l("Hello"),'Hallo');
+ tt(ln("You have %d message","You have %d messages",4),'Du hast 4 Nachrichten');
+ tt(ln("You have %d message","You have %d messages",1),'Du hast 1 Nachricht');
+ tt(ln("You have %d message of %s","You have %d messages of %s",4,'harry'),
+ 'Du hast 4 Nachrichten von harry');
+ tt(ln("You have %d message of %s","You have %d messages of %s",1,'harry'),
+ 'Du hast 1 Nachricht von harry');
+ tt(ln('%2$s brought %1$d message','%2$s brought %1$d messages',1,'harry'),
+ '1 Nachricht gebracht von harry');
+ tt(ln('%2$s has %1$d message','%2$s has %1$d messages',4,'harry'),
+ 'harry hat 4 Nachrichten');
+ tt(l("Change order test %s %s",1,2),'Andere Reihenfolge hier 2 1');
+ tt(l("Other change order test %s %s %s",1,2,3),
+ 'Verhalten aus http://perldoc.perl.org/functions/sprintf.html 3 1 1');
+ tt(lp("alien","Hello"),'Hallo Ausserirdischer');
}
@@ -42,5 +58,11 @@
<body>
<h1>locale_simple.js Translation Test</h1>
<div id="t"></div>
+ <div id="fail" style="display:none">
+ <h4>
+ Please report these failing tests to <a href="mailto:torsten@raudss.us">torsten@raudss.us</a>
+ </h4>
+ Include this output and all informations of your browser you can give. If all tests are failing, then you might miss the part of the distribution which includes the LC_MESSAGES file for the translations.
+ </div>
</body>
</html>

0 comments on commit df5f8de

Please sign in to comment.