Add i18n translations

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@193152 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2005-06-23 14:50:25 +00:00
parent ec9251f2ac
commit 95b40a2b87
3 changed files with 26 additions and 13 deletions

View File

@ -6,7 +6,7 @@
<version>2.0-alpha-3</version>
</parent>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.0-alpha-1</version>
<version>2.0-alpha-2-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Maven PMD Plugin</name>
<inceptionYear>2005</inceptionYear>

View File

@ -40,6 +40,7 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
/**
* Implement the PMD report.
@ -78,7 +79,7 @@ public class PmdReport
*/
public String getName( Locale locale )
{
return "PMD report";
return getBundle( locale ).getString( "report.pmd.name" );
}
/**
@ -86,7 +87,7 @@ public class PmdReport
*/
public String getDescription( Locale locale )
{
return "Verification of coding rules.";
return getBundle( locale ).getString( "report.pmd.description" );
}
/**
@ -134,7 +135,7 @@ public class PmdReport
Report report = new Report();
// TODO: use source roots instead
String sourceDirectory = getProject().getBuild().getSourceDirectory();
PmdReportListener reportSink = new PmdReportListener( sink, sourceDirectory );
PmdReportListener reportSink = new PmdReportListener( sink, sourceDirectory, getBundle( locale ) );
report.addListener( reportSink );
ruleContext.setReport( report );
@ -233,4 +234,9 @@ public class PmdReport
return FileUtils.getFiles( dir, includes, excludesStr.toString() );
}
private static ResourceBundle getBundle( Locale locale )
{
return ResourceBundle.getBundle("pmd-report", locale, PmdReport.class.getClassLoader() );
}
}

View File

@ -23,6 +23,7 @@ import org.codehaus.doxia.sink.Sink;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.util.ResourceBundle;
/**
* Handle events from PMD, converting them into Doxia events.
@ -33,8 +34,6 @@ import java.io.File;
public class PmdReportListener
implements ReportListener
{
private static final String TITLE = "PMD Results";
private Sink sink;
private String sourceDirectory;
@ -43,10 +42,18 @@ public class PmdReportListener
private boolean fileInitialized;
public PmdReportListener( Sink sink, String sourceDirectory )
private ResourceBundle bundle;
public PmdReportListener( Sink sink, String sourceDirectory, ResourceBundle bundle )
{
this.sink = sink;
this.sourceDirectory = sourceDirectory;
this.bundle = bundle;
}
private String getTitle()
{
return bundle.getString( "report.pmd.title" );
}
public void ruleViolationAdded( RuleViolation ruleViolation )
@ -61,10 +68,10 @@ public class PmdReportListener
sink.table();
sink.tableRow();
sink.tableHeaderCell();
sink.text( "Violation" );
sink.text( bundle.getString( "report.pmd.column.violation" ) );
sink.tableHeaderCell_();
sink.tableHeaderCell();
sink.text( "Line" );
sink.text( bundle.getString( "report.pmd.column.line" ) );
sink.tableHeaderCell_();
sink.tableRow_();
@ -90,7 +97,7 @@ public class PmdReportListener
{
sink.head();
sink.title();
sink.text( TITLE );
sink.text( getTitle() );
sink.title_();
sink.head_();
@ -98,11 +105,11 @@ public class PmdReportListener
sink.section1();
sink.sectionTitle1();
sink.text( TITLE );
sink.text( getTitle() );
sink.sectionTitle1_();
sink.paragraph();
sink.text( "The following document contains the results of " );
sink.text( bundle.getString( "report.pmd.pmdlink" ) + " " );
sink.link( "http://pmd.sourceforge.net/" );
sink.text( "PMD" );
sink.link_();
@ -112,7 +119,7 @@ public class PmdReportListener
sink.section1_();
sink.sectionTitle1();
sink.text( "Files" );
sink.text( bundle.getString( "report.pmd.files" ) );
sink.sectionTitle1_();
// TODO files summary