Skip to content

Commit

Permalink
Use localized format to avoid space before colon in English
Browse files Browse the repository at this point in the history
  • Loading branch information
pzygielo authored and michael-o committed Feb 1, 2022
1 parent e7fd10d commit 292df99
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
34 changes: 25 additions & 9 deletions src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.MessageFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -99,12 +100,19 @@ public class InvokerReport
*/
private NumberFormat secondsFormat;

/**
* The format used to print build name and description.
*/
private MessageFormat nameAndDescriptionFormat;

protected void executeReport( Locale locale )
throws MavenReportException
{
DecimalFormatSymbols symbols = new DecimalFormatSymbols( locale );
percentFormat = new DecimalFormat( getText( locale, "report.invoker.format.percent" ), symbols );
secondsFormat = new DecimalFormat( getText( locale, "report.invoker.format.seconds" ), symbols );
nameAndDescriptionFormat =
new MessageFormat( getText( locale, "report.invoker.format.name_with_description" ) );

Sink sink = getSink();

Expand Down Expand Up @@ -283,23 +291,31 @@ private void renderBuildJob( BuildJob buildJob )
{
Sink sink = getSink();
sink.tableRow();
sinkCell( sink, getBuildJobReportName( buildJob ) );
// FIXME image
sinkCell( sink, buildJob.getResult() );
sinkCell( sink, secondsFormat.format( buildJob.getTime() ) );
sinkCell( sink, buildJob.getFailureMessage() );
sink.tableRow_();
}

private String getBuildJobReportName( BuildJob buildJob )
{
StringBuilder buffer = new StringBuilder();
if ( !StringUtils.isEmpty( buildJob.getName() ) && !StringUtils.isEmpty( buildJob.getDescription() ) )
{
buffer.append( buildJob.getName() );
buffer.append( " : " );
buffer.append( buildJob.getDescription() );
buffer.append( getFormattedName( buildJob.getName(), buildJob.getDescription() ) );
}
else
{
buffer.append( buildJob.getProject() );
}
sinkCell( sink, buffer.toString() );
// FIXME image
sinkCell( sink, buildJob.getResult() );
sinkCell( sink, secondsFormat.format( buildJob.getTime() ) );
sinkCell( sink, buildJob.getFailureMessage() );
sink.tableRow_();
return buffer.toString();
}

private String getFormattedName( String name, String description )
{
return nameAndDescriptionFormat.format( new Object[] { name, description } );
}

protected String getOutputDirectory()
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/invoker-report.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ report.invoker.detail.time = Time
report.invoker.detail.message = Message
report.invoker.format.percent = 0.0%
report.invoker.format.seconds = 0.0\u00A0s
report.invoker.format.name_with_description = {0}: {1}
1 change: 1 addition & 0 deletions src/main/resources/invoker-report_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ report.invoker.detail.time = Dur
report.invoker.detail.message = Message
report.invoker.format.percent = 0.0%
report.invoker.format.seconds = 0.0\u00A0s
report.invoker.format.name_with_description = {0} : {1}

0 comments on commit 292df99

Please sign in to comment.