Language l = Language.getInstance(user.getTargetUser().getPreferredLocale());
StringBuffer body = new StringBuffer();
body.append(l.getTranslation("Hi,") + "\n\n");
- body.append(l.getTranslation("A password reset was triggered. Please enter the required text sent to you by support on this page: \nhttps://"));
+ body.append(l.getTranslation("A password reset was triggered. Please enter the required text sent to you by support on this page:"));
+ body.append("\n\nhttps://");
body.append(ServerConstants.getWwwHostNamePortSecure() + PasswordResetPage.PATH);
body.append("?id=");
body.append(id);
Language l = Language.getInstance(assuree.getPreferredLocale());
StringBuffer body = new StringBuffer();
body.append(l.getTranslation("Hi,") + "\n\n");
- body.append(l.getTranslation("A password reset was triggered. If you did a password reset by assurance, please enter your secret password using this form: \nhttps://"));
+ body.append(l.getTranslation("A password reset was triggered. If you did a password reset by assurance, please enter your secret password using this form:"));
+ body.append("\n\nhttps://");
body.append(ServerConstants.getWwwHostNamePortSecure() + PasswordResetPage.PATH);
body.append("?id=");
body.append(id);
package org.cacert.gigi.util;
import java.io.PrintWriter;
+import java.util.Arrays;
import java.util.Map;
import org.cacert.gigi.GigiApiException;
import org.cacert.gigi.dbObjects.User;
import org.cacert.gigi.localisation.Language;
import org.cacert.gigi.output.template.Outputable;
+import org.cacert.gigi.output.template.SprintfCommand;
public class AuthorizationContext implements Outputable {
return getSupporterTicketId() != null && isInGroup(Group.SUPPORTER);
}
+ private static final SprintfCommand sp = new SprintfCommand("Logged in as {0} via {1}.", Arrays.asList("${username}", "${loginMethod}"));
+
+ private static final SprintfCommand inner = new SprintfCommand("{0} (on behalf of {1})", Arrays.asList("${user}", "${target}"));
+
@Override
public void output(PrintWriter out, Language l, Map<String, Object> vars) {
out.println("<div>");
- out.println(l.getTranslation("Logged in as"));
- out.println(": ");
-
- if (target != actor) {
- out.println(((Organisation) target).getName() + " (" + actor.getName().toString() + ")");
- } else {
- out.println(actor.getName().toString());
- }
-
- out.println(l.getTranslation("with"));
- ((Outputable) vars.get("loginMethod")).output(out, l, vars);
- out.println();
+ vars.put("username", new Outputable() {
+
+ @Override
+ public void output(PrintWriter out, Language l, Map<String, Object> vars) {
+ if (target != actor) {
+ vars.put("user", ((Organisation) target).getName().toString());
+ vars.put("target", actor.getName().toString());
+ inner.output(out, l, vars);
+ } else {
+ out.println(actor.getName().toString());
+ }
+ }
+ });
+ sp.output(out, l, vars);
out.println("</div>");
if (supporterTicketId != null) {
out.println("<div>");
package org.cacert.gigi.localisation;
+import java.io.File;
+import java.io.IOException;
import java.lang.reflect.Method;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
lineEnds.length - 1);
String content = new String(((StringLiteral) e).source());
- translationCollector.add(
- content,
- new String(unit.compilationResult.fileName)
- .substring(translationCollector.base
- .getAbsolutePath().length() + 1)
- + ":" + lineNumber);
+ File f0 = new File(new String(unit.compilationResult.fileName))
+ .getAbsoluteFile();
+ File f2 = translationCollector.base.getAbsoluteFile();
+ try {
+ System.out.println(f0.getCanonicalPath());
+ System.out.println(f2.getCanonicalPath());
+ translationCollector.add(content, f0.getCanonicalPath()
+ .substring(f2.getCanonicalPath().length() + 1)
+ + ":"
+ + lineNumber);
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
return;
}
}
public void add(String text, String line) {
+ if(text.contains("\r") || text.contains("\n")){
+ throw new Error("Malformed translation in " + line);
+ }
TranslationEntry i = translations.get(text);
if (i == null) {
translations.put(text, new TranslationEntry(text, line));
add(string,
file.getAbsolutePath().substring(
base.getAbsolutePath().length() + 1)
- + ":0");
+ + ":1");
}
}
}