ngettext fixes thx duck

This commit is contained in:
zzz
2011-03-12 21:32:29 +00:00
parent e3a81f6091
commit 3f141e72b8
4 changed files with 14 additions and 10 deletions

View File

@ -196,12 +196,16 @@ public class ConfigTunnelsHelper extends HelperBase {
// buf.append("<tr><td colspan=\"3\"><br></td></tr>\n");
}
/** to fool xgettext so the following isn't tagged */
private static final String DUMMY1 = "1 ";
private static final String DUMMY2 = "{0} ";
private void renderOptions(StringBuilder buf, int min, int max, int now, String prefix, String name) {
for (int i = min; i <= max; i++) {
buf.append("<option value=\"").append(i).append("\" ");
if (i == now)
buf.append("selected=\"true\" ");
buf.append(">").append(_(i, "1 " + name, "{0} " + name + 's'));
buf.append(">").append(ngettext(DUMMY1 + name, DUMMY2 + name + 's', i));
buf.append("</option>\n");
}
}

View File

@ -63,7 +63,7 @@ public abstract class HelperBase {
}
/** translate (ngettext) @since 0.7.14 */
public String _(int n, String s, String p) {
public String ngettext(String s, String p, int n) {
return Messages.getString(n, s, p, _context);
}

View File

@ -70,11 +70,11 @@ class ProfileOrganizerRenderer {
int failing = 0;
StringBuilder buf = new StringBuilder(16*1024);
buf.append("<h2>").append(_("Peer Profiles")).append("</h2>\n<p>");
buf.append(_(order.size(), "Showing 1 recent profile.", "Showing {0} recent profiles.")).append('\n');
buf.append(ngettext("Showing 1 recent profile.", "Showing {0} recent profiles.", order.size())).append('\n');
if (older > 0)
buf.append(_(older, "Hiding 1 older profile.", "Hiding {0} older profiles.")).append('\n');
buf.append(ngettext("Hiding 1 older profile.", "Hiding {0} older profiles.", older)).append('\n');
if (standard > 0)
buf.append("<a href=\"/profiles?f=1\">").append(_(standard, "Hiding 1 standard profile.", "Hiding {0} standard profiles.")).append("</a>\n");
buf.append("<a href=\"/profiles?f=1\">").append(ngettext("Hiding 1 standard profile.", "Hiding {0} standard profiles.", standard)).append("</a>\n");
buf.append("</p>");
buf.append("<table>");
buf.append("<tr>");
@ -361,7 +361,7 @@ class ProfileOrganizerRenderer {
}
/** translate (ngettext) @since 0.8.5 */
public String _(int n, String s, String p) {
public String ngettext(String s, String p, int n) {
return Messages.getString(n, s, p, _context);
}

View File

@ -141,7 +141,7 @@ public class StatsGenerator {
buf.append("<li><b>").append(_("Lifetime average frequency")).append(":</b> ");
buf.append(DataHelper.formatDuration2(freq.getFrequency()));
buf.append(" (");
buf.append(ngettext((int) freq.getEventCount(), "1 event", "{0} events"));
buf.append(ngettext("1 event", "{0} events", (int) freq.getEventCount()));
buf.append(")</li></ul><br>\n");
}
@ -198,7 +198,7 @@ public class StatsGenerator {
buf.append("; ");
}
buf.append(ngettext((int)curRate.getLastEventCount(), "There was 1 event in this period.", "There were {0} events in this period."));
buf.append(ngettext("There was 1 event in this period.", "There were {0} events in this period.", (int)curRate.getLastEventCount()));
buf.append(' ');
buf.append(_("The period ended {0} ago.", DataHelper.formatDuration2(now - curRate.getLastCoalesceDate())));
} else {
@ -231,7 +231,7 @@ public class StatsGenerator {
buf.append("<li><b>").append(_("Lifetime average value")).append(":</b> ");
buf.append(num(rate.getLifetimeAverageValue()));
buf.append(" (");
buf.append(ngettext((int) rate.getLifetimeEventCount(), "1 event", "{0} events"));
buf.append(ngettext("1 event", "{0} events", (int) rate.getLifetimeEventCount()));
buf.append(")<br></li>" +
"</ul>" +
"<br>\n");
@ -262,7 +262,7 @@ public class StatsGenerator {
}
/** translate a string */
private String ngettext(int n, String s, String p) {
private String ngettext(String s, String p, int n) {
return Messages.getString(n, s, p, _context);
}
}