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 committed Feb 1, 2022
1 parent 7271708 commit d5c734d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
17 changes: 14 additions & 3 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 @@ -296,9 +304,7 @@ 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
{
Expand All @@ -307,6 +313,11 @@ private String getBuildJobReportName( BuildJob buildJob )
return buffer.toString();
}

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

protected String getOutputDirectory()
{
return outputDirectory.getAbsolutePath();
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 d5c734d

Please sign in to comment.