diff options
author | Sasa Zivkov <sasa.zivkov@sap.com> | 2010-05-19 16:59:28 +0200 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-05-19 14:37:16 -0700 |
commit | f3d8a8ecad614906a2c4ec0077cdb24129da6c6d (patch) | |
tree | 34d041692beff0f392c27869f49b76c0fc2053e6 /org.eclipse.jgit.iplog | |
parent | 2e961989e42b1fe7e8bd9eaa7a3d2e88a0d1d001 (diff) | |
download | jgit-f3d8a8ecad614906a2c4ec0077cdb24129da6c6d.tar.gz jgit-f3d8a8ecad614906a2c4ec0077cdb24129da6c6d.zip |
Externalize strings from JGit
The strings are externalized into the root resource bundles.
The resource bundles are stored under the new "resources" source
folder to get proper maven build.
Strings from tests are, in general, not externalized. Only in
cases where it was necessary to make the test pass the strings
were externalized. This was typically necessary in cases where
e.getMessage() was used in assert and the exception message was
slightly changed due to reuse of the externalized strings.
Change-Id: Ic0f29c80b9a54fcec8320d8539a3e112852a1f7b
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Diffstat (limited to 'org.eclipse.jgit.iplog')
13 files changed, 134 insertions, 28 deletions
diff --git a/org.eclipse.jgit.iplog/.classpath b/org.eclipse.jgit.iplog/.classpath index 304e86186a..d7edf529a2 100644 --- a/org.eclipse.jgit.iplog/.classpath +++ b/org.eclipse.jgit.iplog/.classpath @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="resources"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="output" path="bin"/> diff --git a/org.eclipse.jgit.iplog/META-INF/MANIFEST.MF b/org.eclipse.jgit.iplog/META-INF/MANIFEST.MF index 1a0de54a8a..a871ba9811 100644 --- a/org.eclipse.jgit.iplog/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.iplog/META-INF/MANIFEST.MF @@ -11,6 +11,7 @@ Import-Package: org.eclipse.jgit.diff;version="[0.8.0,0.9.0)", org.eclipse.jgit.dircache;version="[0.8.0,0.9.0)", org.eclipse.jgit.errors;version="[0.8.0,0.9.0)", org.eclipse.jgit.lib;version="[0.8.0,0.9.0)", + org.eclipse.jgit.nls;version="[0.8.0,0.9.0)", org.eclipse.jgit.revplot;version="[0.8.0,0.9.0)", org.eclipse.jgit.revwalk;version="[0.8.0,0.9.0)", org.eclipse.jgit.revwalk.filter;version="[0.8.0,0.9.0)", diff --git a/org.eclipse.jgit.iplog/pom.xml b/org.eclipse.jgit.iplog/pom.xml index b03e5ed754..64d1dc1516 100644 --- a/org.eclipse.jgit.iplog/pom.xml +++ b/org.eclipse.jgit.iplog/pom.xml @@ -83,6 +83,9 @@ <include>plugin.properties</include> </includes> </resource> + <resource> + <directory>resources/</directory> + </resource> </resources> <plugins> diff --git a/org.eclipse.jgit.iplog/resources/org/eclipse/jgit/iplog/IpLogText.properties b/org.eclipse.jgit.iplog/resources/org/eclipse/jgit/iplog/IpLogText.properties new file mode 100644 index 0000000000..758620839b --- /dev/null +++ b/org.eclipse.jgit.iplog/resources/org/eclipse/jgit/iplog/IpLogText.properties @@ -0,0 +1,17 @@ +CQString=CQ {0} +CSVParsingError=CSV parsing error: {0} +cannotLock=Cannot lock {0} +cannotSerializeXML=Cannot serialize XML +cannotWrite=Cannot write {0} +committerString=Committer {0} {1} +configurationFileInCommitHasNoProjectsDeclared=Configuration file {0} in commit {1} has no projects declared. +configurationFileInCommitIsInvalid=Configuration file {0} in commit {1} is invalid +contributorString=Contributor {0} +incorrectlyScanned=Incorrectly scanned {0} +invalidDate=Invalid date: {0} +invalidURIFormat=Invalid URI format: {0} +loginFailed=Login as {0} to {1} failed: {2} +pageTitleWas=page title was "{0}" +projectString=Project {0} ({1}) +queryFailed=Query {0} failed: {1} +responseNotHTMLAsExpected=Response not HTML as expected diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CQ.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CQ.java index c2a4fe1195..13781f48ad 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CQ.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CQ.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.iplog; +import java.text.MessageFormat; import java.util.Comparator; /** @@ -156,6 +157,6 @@ class CQ { @Override public String toString() { - return "CQ " + getID(); + return MessageFormat.format(IpLogText.get().CQString, getID()); } } diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CSV.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CSV.java index 8c57edb00f..3f80c7d1fc 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CSV.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/CSV.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.iplog; import java.io.BufferedReader; import java.io.IOException; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -108,7 +109,7 @@ class CSV { } } if (p < line.length() && line.charAt(p) != ',') - throw new IOException("CSV parsing error: " + line); + throw new IOException(MessageFormat.format(IpLogText.get().CSVParsingError, line)); row.add(b.toString()); p++; // skip the trailing comma (if present) diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Committer.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Committer.java index fe84a08ecf..905f99e0f3 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Committer.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Committer.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.iplog; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -172,7 +173,7 @@ class Committer { @Override public String toString() { - return "Committer " + getFirstName() + " " + getLastName(); + return MessageFormat.format(IpLogText.get().committerString, getFirstName(), getLastName()); } /** Date period during which the committer was active. */ diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Contributor.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Contributor.java index cf1f7c1013..9d3771bfb8 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Contributor.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Contributor.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.iplog; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -93,6 +94,6 @@ class Contributor { @Override public String toString() { - return "Contributor " + getName(); + return MessageFormat.format(IpLogText.get().contributorString, getName()); } } diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IPZillaQuery.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IPZillaQuery.java index 7d9f9a64c8..b8db84a89c 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IPZillaQuery.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IPZillaQuery.java @@ -59,6 +59,7 @@ import java.net.ProxySelector; import java.net.URISyntaxException; import java.net.URL; import java.net.URLEncoder; +import java.text.MessageFormat; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -135,8 +136,8 @@ class IPZillaQuery { HttpURLConnection conn = open(csv); if (HttpSupport.response(conn) != HttpURLConnection.HTTP_OK) { - throw new IOException("Query " + csv + " failed: " - + conn.getResponseCode() + " " + conn.getResponseMessage()); + throw new IOException(MessageFormat.format(IpLogText.get().queryFailed + , csv, conn.getResponseCode() + " " + conn.getResponseMessage())); } BufferedReader br = reader(conn); @@ -185,23 +186,23 @@ class IPZillaQuery { out.close(); if (HttpSupport.response(c) != HttpURLConnection.HTTP_OK) { - throw new IOException("Login as " + username + " to " + login - + " failed: " + c.getResponseCode() + " " - + c.getResponseMessage()); + throw new IOException(MessageFormat.format(IpLogText.get().loginFailed + , username, login, c.getResponseCode() + " " + c.getResponseMessage())); } String content = readFully(c); Matcher matcher = Pattern.compile("<title>(.*)</title>", Pattern.CASE_INSENSITIVE).matcher(content); if (!matcher.find()) { - throw new IOException("Login as " + username + " to " + login - + " failed: Response not HTML as expected"); + throw new IOException(MessageFormat.format(IpLogText.get().loginFailed + , username, login, IpLogText.get().responseNotHTMLAsExpected)); } String title = matcher.group(1); if (!"IPZilla Main Page".equals(title)) { - throw new IOException("Login as " + username + " to " + login - + " failed; page title was \"" + title + "\""); + throw new IOException(MessageFormat.format(IpLogText.get().loginFailed + , username, login + , MessageFormat.format(IpLogText.get().pageTitleWas, title))); } } @@ -246,7 +247,7 @@ class IPZillaQuery { try { CookieHandler.getDefault().put(url.toURI(), cols); } catch (URISyntaxException e) { - IOException err = new IOException("Invalid URI format:" + url); + IOException err = new IOException(MessageFormat.format(IpLogText.get().invalidURIFormat, url)); err.initCause(e); throw err; } diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java index d8956afe12..a9fdb81581 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogGenerator.java @@ -48,6 +48,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.OutputStream; +import java.text.MessageFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -209,15 +210,13 @@ public class IpLogGenerator { try { meta.loadFrom(new BlobBasedConfig(null, db, log.getObjectId(0))); } catch (ConfigInvalidException e) { - throw new ConfigInvalidException("Configuration file " - + log.getPathString() + " in commit " + commit.name() - + " is invalid", e); + throw new ConfigInvalidException(MessageFormat.format(IpLogText.get().configurationFileInCommitIsInvalid + , log.getPathString(), commit.name()), e); } if (meta.getProjects().isEmpty()) { - throw new ConfigInvalidException("Configuration file " - + log.getPathString() + " in commit " + commit.name() - + " has no projects declared."); + throw new ConfigInvalidException(MessageFormat.format(IpLogText.get().configurationFileInCommitHasNoProjectsDeclared + , log.getPathString(), commit.name())); } for (Project p : meta.getProjects()) { @@ -274,7 +273,7 @@ public class IpLogGenerator { try { return dt.parse(value); } catch (ParseException e) { - IOException err = new IOException("Invalid date: " + value); + IOException err = new IOException(MessageFormat.format(IpLogText.get().invalidDate, value)); err.initCause(e); throw err; } @@ -411,7 +410,7 @@ public class IpLogGenerator { } if (addedLines < 0) - throw new IOException("Incorrectly scanned " + commit.name()); + throw new IOException(MessageFormat.format(IpLogText.get().incorrectlyScanned, commit.name())); if (1 == addedLines) item.setSize("+1 line"); else @@ -447,17 +446,17 @@ public class IpLogGenerator { s.setOutputProperty(INDENT, "2"); s.transform(new DOMSource(toXML()), new StreamResult(out)); } catch (ParserConfigurationException e) { - IOException err = new IOException("Cannot serialize XML"); + IOException err = new IOException(IpLogText.get().cannotSerializeXML); err.initCause(e); throw err; } catch (TransformerConfigurationException e) { - IOException err = new IOException("Cannot serialize XML"); + IOException err = new IOException(IpLogText.get().cannotSerializeXML); err.initCause(e); throw err; } catch (TransformerException e) { - IOException err = new IOException("Cannot serialize XML"); + IOException err = new IOException(IpLogText.get().cannotSerializeXML); err.initCause(e); throw err; } diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java index d0a5279abb..8d73b02fd5 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.iplog; import java.io.File; import java.io.IOException; import java.net.URL; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -155,7 +156,7 @@ public class IpLogMeta { LockFile lf = new LockFile(file); if (!lf.lock()) - throw new IOException("Cannot lock " + file); + throw new IOException(MessageFormat.format(IpLogText.get().cannotLock, file)); try { FileBasedConfig cfg = new FileBasedConfig(file); cfg.load(); @@ -181,7 +182,7 @@ public class IpLogMeta { lf.write(Constants.encode(cfg.toText())); if (!lf.commit()) - throw new IOException("Cannot write " + file); + throw new IOException(MessageFormat.format(IpLogText.get().cannotWrite, file)); } finally { lf.unlock(); } diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogText.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogText.java new file mode 100644 index 0000000000..2067c5f634 --- /dev/null +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogText.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2010, Sasa Zivkov <sasa.zivkov@sap.com> + * and other copyright owners as documented in the project's IP log. + * + * This program and the accompanying materials are made available + * under the terms of the Eclipse Distribution License v1.0 which + * accompanies this distribution, is reproduced below, and is + * available at http://www.eclipse.org/org/documents/edl-v10.php + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * - Neither the name of the Eclipse Foundation, Inc. nor the + * names of its contributors may be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.eclipse.jgit.iplog; + +import org.eclipse.jgit.nls.NLS; +import org.eclipse.jgit.nls.TranslationBundle; + +/** + * Translation bundle for JGit IP Log + */ +public class IpLogText extends TranslationBundle { + + /** + * @return an instance of this translation bundle + */ + public static IpLogText get() { + return NLS.getBundleFor(IpLogText.class); + } + + /***/ public String CQString; + /***/ public String CSVParsingError; + /***/ public String cannotLock; + /***/ public String cannotSerializeXML; + /***/ public String cannotWrite; + /***/ public String committerString; + /***/ public String configurationFileInCommitHasNoProjectsDeclared; + /***/ public String configurationFileInCommitIsInvalid; + /***/ public String contributorString; + /***/ public String incorrectlyScanned; + /***/ public String invalidDate; + /***/ public String invalidURIFormat; + /***/ public String loginFailed; + /***/ public String pageTitleWas; + /***/ public String projectString; + /***/ public String queryFailed; + /***/ public String responseNotHTMLAsExpected; +} diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Project.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Project.java index 15b79cede5..efa1fed793 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Project.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/Project.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.iplog; +import java.text.MessageFormat; import java.util.Collections; import java.util.Comparator; import java.util.Set; @@ -128,6 +129,6 @@ class Project { @Override public String toString() { - return "Project " + getID() + " (" + getName() + ")"; + return MessageFormat.format(IpLogText.get().projectString, getID(), getName()); } } |