From 6ff1248b2b4ec77dff47a7f1eda99710d90c3eaf Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Mon, 9 Nov 2015 11:20:10 +1000 Subject: [PATCH] Fix warning "Use of '_' might not be supported..." --- .../client/commands/ConsoleInteractor.java | 6 +-- .../commands/ConsoleInteractorImpl.java | 8 ++-- .../org/zanata/client/commands/Messages.java | 4 +- .../zanata/client/commands/OptionsUtil.java | 11 ++--- .../client/commands/TransFileResolver.java | 4 +- .../zanata/client/commands/UpdateChecker.java | 22 +++++----- .../client/commands/init/InitCommand.java | 44 +++++++++---------- .../commands/init/ProjectConfigHandler.java | 8 ++-- .../commands/init/ProjectIterationPrompt.java | 23 +++++----- .../client/commands/init/ProjectPrompt.java | 29 ++++++------ .../commands/init/SourceConfigPrompt.java | 32 +++++++------- .../commands/init/TransConfigPrompt.java | 10 ++--- .../commands/init/UserConfigHandler.java | 12 ++--- .../client/commands/OptionsUtilTest.java | 10 ++--- .../client/commands/UpdateCheckerTest.java | 6 +-- .../client/commands/init/InitCommandTest.java | 2 +- .../commands/init/UserConfigHandlerTest.java | 7 ++- 17 files changed, 116 insertions(+), 122 deletions(-) diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/ConsoleInteractor.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/ConsoleInteractor.java index 99bb3f71..df18992e 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/ConsoleInteractor.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/ConsoleInteractor.java @@ -22,7 +22,7 @@ import com.google.common.base.Strings; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; public interface ConsoleInteractor { /** @@ -69,7 +69,7 @@ public boolean isAnswerValid(String answer) { @Override public String invalidErrorMessage(String answer) { - return String.format(_("expected.and.actual.answer"), "y or n", + return String.format(get("expected.and.actual.answer"), "y or n", answer); } }; @@ -81,7 +81,7 @@ public boolean isAnswerValid(String answer) { @Override public String invalidErrorMessage(String answer) { - return _("no.blank.answer"); + return get("no.blank.answer"); } }; static final AnswerValidator ANY = new AnswerValidator() { diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/ConsoleInteractorImpl.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/ConsoleInteractorImpl.java index b37095b3..d19ae4b4 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/ConsoleInteractorImpl.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/ConsoleInteractorImpl.java @@ -33,7 +33,7 @@ import com.google.common.collect.Lists; import static org.zanata.client.commands.StringUtil.indent; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; /** * @author Patrick Huang translationFileExtension) { FileMappingRule rule = PROJECT_TYPE_FILE_MAPPING_RULES.get(projectType); - checkState(rule != null, _("no.default.mapping"), projectType); + checkState(rule != null, get("no.default.mapping"), projectType); String relativePath = new FileMappingRuleHandler(rule, projectType, opts) .getRelativeTransFilePathForSourceDoc(qualifiedSrcDocName, localeMapping, translationFileExtension); diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/UpdateChecker.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/UpdateChecker.java index aa523f6a..509b7ad8 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/UpdateChecker.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/UpdateChecker.java @@ -21,7 +21,7 @@ package org.zanata.client.commands; import static org.zanata.client.commands.ConsoleInteractorImpl.AnswerValidator; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; import static org.zanata.util.VersionUtility.getVersionInfo; import java.io.BufferedWriter; @@ -103,8 +103,8 @@ public boolean needToCheckUpdates(boolean interactiveMode) { try { if (!updateMarker.exists()) { createUpdateMarkerFile(updateMarker); - console.printfln(_("update.marker.created"), updateMarker); - console.printfln(_("update.marker.hint")); + console.printfln(get("update.marker.created"), updateMarker); + console.printfln(get("update.marker.hint")); return true; } // read the content and see if we need to check @@ -115,7 +115,7 @@ public boolean needToCheckUpdates(boolean interactiveMode) { boolean timeToCheck = daysPassed.compareTo(frequency.days()) >= 0; boolean noAsking = readNoAsking(props); if (timeToCheck && !noAsking && interactiveMode) { - console.printf(_("check.update.yes.no"), daysPassed.getDays()); + console.printf(get("check.update.yes.no"), daysPassed.getDays()); String check = console.expectAnswerWithRetry( AnswerValidator.YES_NO); if (check.toLowerCase().startsWith("n")) { @@ -159,15 +159,15 @@ private static Properties loadFileToProperties(File updateMarker) { private static void createUpdateMarkerFile(File updateMarker) throws IOException { boolean created = updateMarker.createNewFile(); - Preconditions.checkState(created, _("create.file.failure"), + Preconditions.checkState(created, get("create.file.failure"), updateMarker); String today = DATE_FORMATTER.print(new DateTime()); Properties props = new Properties(); props.setProperty(LAST_CHECKED, today); - props.setComment(FREQUENCY, _("valid.frequency")); + props.setComment(FREQUENCY, get("valid.frequency")); props.setProperty(FREQUENCY, "weekly"); props.setProperty(NO_ASKING, "true"); - props.setComment(NO_ASKING, _("no.check.update.prompt")); + props.setComment(NO_ASKING, get("no.check.update.prompt")); props.store(new BufferedWriter(new FileWriterWithEncoding(updateMarker, Charsets.UTF_8)), null); } @@ -178,9 +178,9 @@ public void checkNewerVersion() { return; } if (latestVersion.get().compareTo(currentVersionNo) > 0) { - console.printfln(_("suggest.update"), latestVersion.get()); + console.printfln(get("suggest.update"), latestVersion.get()); } else { - console.printfln(_("latest.version.confirm")); + console.printfln(get("latest.version.confirm")); } try { Properties props = loadFileToProperties(updateMarker); @@ -220,12 +220,12 @@ private Optional checkLatestVersion(ConsoleInteractor console) { log.debug( "Failed to resolve latest client artifact [status {}]. Ignored", response.getStatus()); - console.printfln(_("check.update.failed")); + console.printfln(get("check.update.failed")); return Optional.absent(); } } catch (Exception e) { log.warn("Exception when checking updates", e); - console.printfln(_("check.update.failed")); + console.printfln(get("check.update.failed")); return Optional.absent(); } // cheap xml parsing diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/InitCommand.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/InitCommand.java index ade6664d..6689c2dd 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/InitCommand.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/InitCommand.java @@ -25,7 +25,7 @@ import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Hint; import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Question; import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Warning; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; import java.io.File; import java.io.IOException; @@ -142,42 +142,42 @@ protected void ensureServerVersion() { getClientFactory().getServerVersionInfo().getVersionNo(); if (new VersionComparator().compare(serverVersion, "3.4.0") < 0) { - console.printfln(Warning, _("server.incompatible")); - console.printfln(Hint, _("server.incompatible.hint")); - throw new RuntimeException(_("server.incompatible")); + console.printfln(Warning, get("server.incompatible")); + console.printfln(Hint, get("server.incompatible.hint")); + throw new RuntimeException(get("server.incompatible")); } } private void displayAdviceAboutWhatIsNext(boolean hasOldConfig) { - console.printfln(_("what.next")); + console.printfln(get("what.next")); if (hasOldConfig) { - console.printfln(_("compare.project.config"), + console.printfln(get("compare.project.config"), projectConfigHandler.getBackup()); } - console.printfln(_("view.project"), + console.printfln(get("view.project"), getProjectIterationUrl(getOpts().getUrl(), getOpts().getProj(), getOpts().getProjectVersion())); if (isInvokedByMaven()) { - console.printfln(_("mvn.push.source")); - console.printfln(_("mvn.push.both")); - console.printfln(_("mvn.push.trans")); - console.printfln(_("mvn.help")); + console.printfln(get("mvn.push.source")); + console.printfln(get("mvn.push.both")); + console.printfln(get("mvn.push.trans")); + console.printfln(get("mvn.help")); } else { - console.printfln(_("cli.push.source")); - console.printfln(_("cli.push.both")); - console.printfln(_("cli.push.trans")); - console.printfln(_("cli.help")); + console.printfln(get("cli.push.source")); + console.printfln(get("cli.push.both")); + console.printfln(get("cli.push.trans")); + console.printfln(get("cli.help")); } - console.printfln(_("browse.online.help")); + console.printfln(get("browse.online.help")); } private void advancedSettingsReminder() { ConfigurableProjectOptions opts = getOpts(); - console.printfln(Warning, _("customize.languages.warning")); - console.printfln(Hint, _("view.project"), + console.printfln(Warning, get("customize.languages.warning")); + console.printfln(Hint, get("view.project"), getProjectIterationUrl(opts.getUrl(), opts.getProj(), opts.getProjectVersion())); - console.printf(Question, _("continue.yes.no")); + console.printf(Question, get("continue.yes.no")); console.expectYes(); } @@ -191,7 +191,7 @@ private void applyConfigFileSilently() OptionsUtil.applyConfigFiles(opts); logger.setLevel(preLevel); console.printfln( - Confirmation, _("project.version.type.confirmation"), + Confirmation, get("project.version.type.confirmation"), opts.getProjectType(), opts.getProj(), opts .getProjectVersion()); } @@ -209,9 +209,9 @@ private static String getProjectIterationUrl(URL server, String projectSlug, public static void offerRetryOnServerError(Exception e, ConsoleInteractor consoleInteractor) { - consoleInteractor.printfln(Warning, _("server.error"), + consoleInteractor.printfln(Warning, get("server.error"), Throwables.getRootCause(e).getMessage()); - consoleInteractor.printf(Question, _("server.error.try.again")); + consoleInteractor.printf(Question, get("server.error.try.again")); consoleInteractor.expectYes(); } diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/ProjectConfigHandler.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/ProjectConfigHandler.java index 813e46f7..2f6a91a7 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/ProjectConfigHandler.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/ProjectConfigHandler.java @@ -32,7 +32,7 @@ import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Confirmation; import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Question; import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Warning; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; /** * @author Patrick Huang @@ -59,8 +59,8 @@ protected void handleExistingProjectConfig() throws IOException { File projectConfig = getOpts().getProjectConfig(); if (projectConfig.exists()) { consoleInteractor - .printfln(Warning, _("project.config.exists")) - .printf(Question, _("continue.yes.no")); + .printfln(Warning, get("project.config.exists")) + .printf(Question, get("continue.yes.no")); consoleInteractor.expectYes(); // back up old zanata.xml String suffix = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss").format( @@ -69,7 +69,7 @@ protected void handleExistingProjectConfig() throws IOException { "zanata.xml." + suffix); FileUtils.moveFile(projectConfig, backup); consoleInteractor - .printfln(Confirmation, _("backup.old.project.config"), backup); + .printfln(Confirmation, get("backup.old.project.config"), backup); clearValuesSetByConfigurableMojo(); } diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/ProjectIterationPrompt.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/ProjectIterationPrompt.java index 2d1e60e9..12eb509f 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/ProjectIterationPrompt.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/ProjectIterationPrompt.java @@ -25,15 +25,13 @@ import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Hint; import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Question; import static org.zanata.client.commands.ConsoleInteractorImpl.AnswerValidatorImpl.expect; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; import java.util.List; import org.zanata.client.commands.ConsoleInteractor; import org.zanata.client.commands.ConsoleInteractorImpl; import org.zanata.common.EntityStatus; -import org.zanata.rest.client.ProjectClient; -import org.zanata.rest.client.ProjectIterationClient; import org.zanata.rest.client.RestClientFactory; import org.zanata.rest.dto.Project; import org.zanata.rest.dto.ProjectIteration; @@ -41,7 +39,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.base.Predicate; -import com.google.common.base.Strings; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.sun.jersey.api.client.UniformInterfaceException; @@ -63,12 +60,12 @@ class ProjectIterationPrompt { } public void selectOrCreateNewVersion() { - consoleInteractor.printfln(_("do.you.want.to")); + consoleInteractor.printfln(get("do.you.want.to")); consoleInteractor.printf("1)") - .printfln(Hint, _("project.version.select")); + .printfln(Hint, get("project.version.select")); consoleInteractor.printf("2)") - .printfln(Hint, _("project.version.create")); - consoleInteractor.printf(Question, _("select.or.create")); + .printfln(Hint, get("project.version.create")); + consoleInteractor.printf(Question, get("select.or.create")); String answer = consoleInteractor.expectAnswerWithRetry( expect("1", "2")); if (answer.equals("1")) { @@ -81,7 +78,7 @@ public void selectOrCreateNewVersion() { @VisibleForTesting protected void selectVersion() { Project project = clientFactory.getProjectClient(opts.getProj()).get(); - consoleInteractor.printfln(_("available.versions"), project.getName()); + consoleInteractor.printfln(get("available.versions"), project.getName()); int oneBasedIndex = 1; List versionIndexes = Lists.newArrayList(); Iterable activeIterations = Iterables @@ -94,7 +91,7 @@ protected void selectVersion() { .printfln(Hint, iteration.getId()); oneBasedIndex++; } - consoleInteractor.printf(Question, _("select.version.prompt")); + consoleInteractor.printf(Question, get("select.version.prompt")); String selection = consoleInteractor.expectAnswerWithRetry(expect(versionIndexes)); ProjectIteration projectIteration = Iterables.get(activeIterations, @@ -113,7 +110,7 @@ private String resolveProjectType(Project project, } else { String projectTypes = Joiner.on(", ").join(ProjectPrompt.PROJECT_TYPE_LIST); - consoleInteractor.printfln(Question, _("project.type.prompt"), + consoleInteractor.printfln(Question, get("project.type.prompt"), projectTypes); return consoleInteractor.expectAnswerWithRetry( ConsoleInteractorImpl.AnswerValidatorImpl @@ -123,7 +120,7 @@ private String resolveProjectType(Project project, @VisibleForTesting protected void createNewVersion() { - consoleInteractor.printfln(Question, _("project.version.id.prompt")); + consoleInteractor.printfln(Question, get("project.version.id.prompt")); String versionId = consoleInteractor.expectAnyAnswer(); ProjectIteration iteration = new ProjectIteration(versionId); iteration.setProjectType(opts.getProjectType()); @@ -135,7 +132,7 @@ protected void createNewVersion() { createNewVersion(); } opts.setProjectVersion(versionId); - consoleInteractor.printfln(Confirmation, _("project.version.created")); + consoleInteractor.printfln(Confirmation, get("project.version.created")); } diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/ProjectPrompt.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/ProjectPrompt.java index dbe9273a..97d499eb 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/ProjectPrompt.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/ProjectPrompt.java @@ -24,7 +24,7 @@ import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Hint; import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Question; import static org.zanata.client.commands.ConsoleInteractorImpl.AnswerValidatorImpl; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; import java.util.Collections; import java.util.List; @@ -33,7 +33,6 @@ import org.zanata.common.EntityStatus; import org.zanata.common.ProjectType; import org.zanata.rest.client.ProjectClient; -import org.zanata.rest.client.ProjectsClient; import org.zanata.rest.client.RestClientFactory; import org.zanata.rest.dto.Project; @@ -78,10 +77,10 @@ class ProjectPrompt { * If creating, also ask for Project type. */ public void selectOrCreateNewProjectAndVersion() { - consoleInteractor.printfln(_("do.you.want.to")); - consoleInteractor.printf("1)").printfln(Hint, _("project.select")); - consoleInteractor.printf("2)").printfln(Hint, _("project.create")); - consoleInteractor.printf(Question, _("select.or.create")); + consoleInteractor.printfln(get("do.you.want.to")); + consoleInteractor.printf("1)").printfln(Hint, get("project.select")); + consoleInteractor.printf("2)").printfln(Hint, get("project.create")); + consoleInteractor.printf(Question, get("select.or.create")); String answer = consoleInteractor.expectAnswerWithRetry( AnswerValidatorImpl.expect("1", "2")); if (answer.equals("1")) { @@ -94,9 +93,9 @@ public void selectOrCreateNewProjectAndVersion() { @VisibleForTesting protected void selectProject() { ensureActiveProjects(); - consoleInteractor.printfln(_("available.projects")); + consoleInteractor.printfln(get("available.projects")); listFilteredProjectsPrefixedByNumber(); - consoleInteractor.printf(Question, _("select.project.prompt")); + consoleInteractor.printf(Question, get("select.project.prompt")); String selection = consoleInteractor.expectAnyAnswer(); if (selectionIsFilter(selection, filteredProjects)) { @@ -109,7 +108,7 @@ protected void selectProject() { opts.setProj(projectId); // TODO server returns Upper case project type!!! opts.setProjectType(project.getDefaultType().toLowerCase()); - consoleInteractor.printfln(Confirmation, _("project.confirmation"), + consoleInteractor.printfln(Confirmation, get("project.confirmation"), opts.getProj()); projectIterationPrompt.selectOrCreateNewVersion(); } @@ -187,14 +186,14 @@ protected void setAllProjectsAndFilteredProjects(List allProjects, @VisibleForTesting protected void createNewProject() { - consoleInteractor.printfln(_("create.project.help")); - consoleInteractor.printfln(Hint, _("project.id.constraint")); - consoleInteractor.printfln(Question, _("project.id.prompt")); + consoleInteractor.printfln(get("create.project.help")); + consoleInteractor.printfln(Hint, get("project.id.constraint")); + consoleInteractor.printfln(Question, get("project.id.prompt")); String projectId = consoleInteractor.expectAnyAnswer(); - consoleInteractor.printfln(Question, _("project.name.prompt")); + consoleInteractor.printfln(Question, get("project.name.prompt")); String projectName = consoleInteractor.expectAnyAnswer(); String projectTypes = Joiner.on(", ").join(PROJECT_TYPE_LIST); - consoleInteractor.printfln(Question, _("project.type.prompt"), projectTypes); + consoleInteractor.printfln(Question, get("project.type.prompt"), projectTypes); String projectType = consoleInteractor.expectAnswerWithRetry( AnswerValidatorImpl.expect(PROJECT_TYPE_LIST)); @@ -208,7 +207,7 @@ protected void createNewProject() { createNewProject(); } } - consoleInteractor.printfln(Confirmation, _("project.created")); + consoleInteractor.printfln(Confirmation, get("project.created")); opts.setProj(projectId); opts.setProjectType(projectType); projectIterationPrompt.createNewVersion(); diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/SourceConfigPrompt.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/SourceConfigPrompt.java index 0df88386..8e65671e 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/SourceConfigPrompt.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/SourceConfigPrompt.java @@ -36,8 +36,6 @@ import org.zanata.client.commands.push.PushCommand; import org.zanata.client.commands.push.PushOptions; import org.zanata.client.commands.push.PushOptionsImpl; -import org.zanata.rest.client.AsyncProcessClient; -import org.zanata.rest.client.CopyTransClient; import org.zanata.rest.client.RestClientFactory; import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Hint; @@ -45,7 +43,7 @@ import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Warning; import static org.zanata.client.commands.StringUtil.indent; import static org.zanata.client.commands.ConsoleInteractorImpl.AnswerValidatorImpl.*; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; /** * Prompt for src dir. @@ -95,25 +93,25 @@ public SourceConfigPrompt( } SourceConfigPrompt promptUser() throws Exception { - console.printf(Question, _("src.dir.prompt")); + console.printf(Question, get("src.dir.prompt")); String localSrcDir = console.expectAnyNotBlankAnswer(); File srcDir = new File(localSrcDir); if (!srcDir.exists()) { - console.printfln(Warning, _("src.dir.not.exist"), + console.printfln(Warning, get("src.dir.not.exist"), localSrcDir); return new SourceConfigPrompt(console, opts).promptUser(); } console.blankLine(); - console.printfln(Hint, _("includes.question")); - console.printfln(_("includes.usage.1")); - console.printfln(_("includes.usage.2")); - console.printfln(_("includes.usage.3")); - console.printf(Question, _("includes.prompt")); + console.printfln(Hint, get("includes.question")); + console.printfln(get("includes.usage.1")); + console.printfln(get("includes.usage.2")); + console.printfln(get("includes.usage.3")); + console.printf(Question, get("includes.prompt")); includes = console.expectAnyAnswer(); console.blankLine(); - console.printfln(Hint, _("excludes.question")); - console.printfln(_("excludes.usage")); - console.printf(Question, _("excludes.prompt")); + console.printfln(Hint, get("excludes.question")); + console.printfln(get("excludes.usage")); + console.printf(Question, get("excludes.prompt")); excludes = console.expectAnyAnswer(); pushOptions.setSrcDir(srcDir); @@ -122,14 +120,14 @@ SourceConfigPrompt promptUser() throws Exception { console.blankLine(); docNames = findDocNames(); if (docNames.isEmpty()) { - console.printfln(_("no.source.doc.found")); + console.printfln(get("no.source.doc.found")); } else { - console.printfln(_("found.source.docs")); + console.printfln(get("found.source.docs")); for (String docName : docNames) { console.printfln("%s%s", indent(8), docName); } } - console.printf(Question, _("source.doc.confirm.yes.no")); + console.printf(Question, get("source.doc.confirm.yes.no")); String answer = console.expectAnswerWithRetry(YES_NO); if (answer.toLowerCase().startsWith("n")) { hintAdvancedConfigurations(); @@ -152,7 +150,7 @@ private Set findDocNames() throws IOException { } private void hintAdvancedConfigurations() { - console.printfln(Hint, _("more.src.options.hint")); + console.printfln(Hint, get("more.src.options.hint")); console.printfln(Hint, " - %s", getUsageFromOptionAnnotation(PushOptionsImpl.class, diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/TransConfigPrompt.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/TransConfigPrompt.java index 8534d67b..ac32b48d 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/TransConfigPrompt.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/TransConfigPrompt.java @@ -40,7 +40,7 @@ import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Question; import static org.zanata.client.commands.StringUtil.indent; import static org.zanata.client.commands.ConsoleInteractorImpl.AnswerValidatorImpl.*; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; /** * Prompt for trans dir, @@ -81,7 +81,7 @@ public TransConfigPrompt(ConsoleInteractor console, } TransConfigPrompt promptUser() throws Exception { - console.printf(Question, _("trans.dir.prompt")); + console.printf(Question, get("trans.dir.prompt")); String localTransDir = console.expectAnyNotBlankAnswer(); File transDir = new File(localTransDir); pullOptions.setTransDir(transDir); @@ -92,14 +92,14 @@ TransConfigPrompt promptUser() throws Exception { Iterable transFiles = Iterables.transform(srcFilesSample, new ToTransFileNameFunction(strategy, localeMapping)); - console.printfln(Hint, _("trans.doc.preview"), localeMapping.getLocale()); + console.printfln(Hint, get("trans.doc.preview"), localeMapping.getLocale()); for (String transFile : transFiles) { console.printfln("%s%s", indent(8), transFile); } if (remainingFileNumber > 0) { - console.printfln(_("remaining.files"), remainingFileNumber); + console.printfln(get("remaining.files"), remainingFileNumber); } - console.printf(Question, _("trans.dir.confirm.yes.no")); + console.printf(Question, get("trans.dir.confirm.yes.no")); String answer = console.expectAnswerWithRetry(YES_NO); if (answer.toLowerCase().startsWith("n")) { return new TransConfigPrompt(console, opts, srcFilesSample) diff --git a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/UserConfigHandler.java b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/UserConfigHandler.java index 75d2046c..5b3d515b 100644 --- a/zanata-client-commands/src/main/java/org/zanata/client/commands/init/UserConfigHandler.java +++ b/zanata-client-commands/src/main/java/org/zanata/client/commands/init/UserConfigHandler.java @@ -38,7 +38,7 @@ import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.*; import static org.zanata.client.commands.ConsoleInteractorImpl.AnswerValidatorImpl.*; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; /** * @author Patrick Huang @@ -64,7 +64,7 @@ public UserConfigHandler(ConsoleInteractor consoleInteractor, InitOptions opts) protected void verifyUserConfig() throws Exception { File userConfig = opts.getUserConfig(); if (!userConfig.exists()) { - String msg = _("missing.user.config"); + String msg = get("missing.user.config"); log.warn(msg); throw new RuntimeException(msg); } @@ -76,20 +76,20 @@ protected void verifyUserConfig() throws Exception { // apply user config if (serverUrls.isEmpty()) { - String msg = _("missing.server.url"); + String msg = get("missing.server.url"); log.warn(msg); throw new RuntimeException(msg); } if (serverUrls.size() == 1) { opts.setUrl(serverUrls.get(0)); } else { - consoleInteractor.printfln(_("found.servers"), opts.getUserConfig().getName()); + consoleInteractor.printfln(get("found.servers"), opts.getUserConfig().getName()); List answers = listServerUrlsPrefixedWithNumber(serverUrls); - consoleInteractor.printf(Question, _("which.server")); + consoleInteractor.printf(Question, get("which.server")); String chosenNumber = consoleInteractor.expectAnswerWithRetry(expect(answers)); URL url = serverUrls.get(Integer.parseInt(chosenNumber) - 1); - consoleInteractor.printfln(Confirmation, _("server.selection"), url); + consoleInteractor.printfln(Confirmation, get("server.selection"), url); opts.setUrl(url); } OptionsUtil.applyUserConfig(opts, config); diff --git a/zanata-client-commands/src/test/java/org/zanata/client/commands/OptionsUtilTest.java b/zanata-client-commands/src/test/java/org/zanata/client/commands/OptionsUtilTest.java index 7b90eac8..681445d4 100644 --- a/zanata-client-commands/src/test/java/org/zanata/client/commands/OptionsUtilTest.java +++ b/zanata-client-commands/src/test/java/org/zanata/client/commands/OptionsUtilTest.java @@ -5,7 +5,7 @@ import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Question; import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Warning; import static org.zanata.client.commands.FileMappingRuleHandler.Placeholders.allHolders; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; import java.io.File; @@ -108,7 +108,7 @@ public void willWarnUserIfRuleSeemsWrong() { opts.setFileMappingRules(Lists.newArrayList(new FileMappingRule(rule))); OptionsUtil.checkPotentialMistakesInRules(opts, console); - verify(console).printfln(Warning, _("unrecognized.variables"), + verify(console).printfln(Warning, get("unrecognized.variables"), allHolders(), rule); } @@ -119,9 +119,9 @@ public void willAskUserToConfirmIfRuleSeemsWrongAndInInteractiveMode() { opts.setFileMappingRules(Lists.newArrayList(new FileMappingRule(rule))); OptionsUtil.checkPotentialMistakesInRules(opts, console); - verify(console).printfln(Warning, _("unrecognized.variables"), + verify(console).printfln(Warning, get("unrecognized.variables"), allHolders(), rule); - verify(console).printfln(Question, _("confirm.rule")); + verify(console).printfln(Question, get("confirm.rule")); } @Test @@ -132,6 +132,6 @@ public void willThrowExceptionIfRuleIsInvalid() { OptionsUtil.checkPotentialMistakesInRules(opts, console); - verify(console).printfln(Warning, _("invalid.rule"), rule); + verify(console).printfln(Warning, get("invalid.rule"), rule); } } diff --git a/zanata-client-commands/src/test/java/org/zanata/client/commands/UpdateCheckerTest.java b/zanata-client-commands/src/test/java/org/zanata/client/commands/UpdateCheckerTest.java index 2ea36f3b..16d67c03 100644 --- a/zanata-client-commands/src/test/java/org/zanata/client/commands/UpdateCheckerTest.java +++ b/zanata-client-commands/src/test/java/org/zanata/client/commands/UpdateCheckerTest.java @@ -33,7 +33,7 @@ import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; public class UpdateCheckerTest { private final DateTimeFormatter dateFormat = @@ -85,7 +85,7 @@ public void noMarkerFileYetWillCreateFileAndCheckUpdate() throws Exception { assertThat(properties.getProperty("frequency"), Matchers.equalTo( "weekly")); assertThat(properties.getComment("frequency"), Matchers.equalTo( - _("valid.frequency"))); + get("valid.frequency"))); } @Test public void willNotCheckIfUserSaysNo() throws Exception { @@ -159,7 +159,7 @@ public void canCheckForUpdates() throws Exception { checker = new UpdateChecker(url, marker, mockConsole, currentVersion); checker.checkNewerVersion(); - String expectedString = Messages._("suggest.update"); + String expectedString = Messages.get("suggest.update"); verify(mockConsole, atLeastOnce()).printfln( outputStringCaptor.capture(), outputArgsCaptor.capture()); diff --git a/zanata-client-commands/src/test/java/org/zanata/client/commands/init/InitCommandTest.java b/zanata-client-commands/src/test/java/org/zanata/client/commands/init/InitCommandTest.java index 3c868406..6fe2be82 100644 --- a/zanata-client-commands/src/test/java/org/zanata/client/commands/init/InitCommandTest.java +++ b/zanata-client-commands/src/test/java/org/zanata/client/commands/init/InitCommandTest.java @@ -100,7 +100,7 @@ public void willQuitIfServerApiVersionDoesNotSupportInit() throws Exception { expectException.expect(RuntimeException.class); expectException.expectMessage(Matchers.equalTo(Messages - ._("server.incompatible"))); + .get("server.incompatible"))); when(clientFactory.getServerVersionInfo()).thenReturn( new VersionInfo("3.3.1", "unknown", "unknown")); diff --git a/zanata-client-commands/src/test/java/org/zanata/client/commands/init/UserConfigHandlerTest.java b/zanata-client-commands/src/test/java/org/zanata/client/commands/init/UserConfigHandlerTest.java index 19b49e0c..069bec21 100644 --- a/zanata-client-commands/src/test/java/org/zanata/client/commands/init/UserConfigHandlerTest.java +++ b/zanata-client-commands/src/test/java/org/zanata/client/commands/init/UserConfigHandlerTest.java @@ -13,14 +13,13 @@ import org.junit.rules.TemporaryFolder; import org.mockito.Mockito; import org.zanata.client.commands.ConsoleInteractor; -import org.zanata.client.commands.Messages; import org.zanata.client.commands.MockConsoleInteractor; import com.google.common.base.Charsets; import com.google.common.io.Files; import static org.hamcrest.MatcherAssert.assertThat; -import static org.zanata.client.commands.Messages._; +import static org.zanata.client.commands.Messages.get; public class UserConfigHandlerTest { @Rule @@ -58,7 +57,7 @@ private void ensureUserConfigExistsWithOneServer() throws IOException { @Test public void exitWhenThereIsNoUserConfig() throws Exception { expectException.expect(RuntimeException.class); - expectException.expectMessage(_("missing.user.config")); + expectException.expectMessage(get("missing.user.config")); opts.setUserConfig(new File("/planet/Mars/zanata.ini")); handler.verifyUserConfig(); @@ -67,7 +66,7 @@ public void exitWhenThereIsNoUserConfig() throws Exception { @Test public void willExitWhenThereIsNoServerUrlInFile() throws Exception { expectException.expect(RuntimeException.class); - expectException.expectMessage(_("missing.server.url")); + expectException.expectMessage(get("missing.server.url")); // wipe contents in the file BufferedWriter writer =