Skip to content

Commit

Permalink
Properly handling plurals
Browse files Browse the repository at this point in the history
  • Loading branch information
leinardi committed Aug 31, 2018
1 parent a25c48e commit b351480
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 130 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ intellij {
version ideaVersion
pluginName 'Pylint'
downloadSources Boolean.valueOf(downloadIdeaSources)
updateSinceUntilBuild = false
if (hasPyCharm) {
alternativeIdePath pycharmPath
} else if (hasPythonPlugin) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#
version=0.1.0
ideaVersion=2018.2.1
ideaVersion=2016.1
downloadIdeaSources=true
#######################################################################################################################
# Uncomment one of the following settings: either pycharmPath or pythonPlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public JComponent createComponent() {
return configPanel.getPanel();
}

@Override
public void reset() {
}

@Override
public boolean isModified() {
boolean result = !configPanel.getPathToPylint().equals(pylintConfigService.getPathToPylint());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.leinardi.pycharm.pylint.toolwindow;

import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiFileSystemItem;
import com.leinardi.pycharm.pylint.PylintBundle;
Expand Down Expand Up @@ -195,9 +196,10 @@ public void setModel(final Map<PsiFile, List<Problem>> results,
}

if (hasProblems) {
setRootText(PylintBundle.message("plugin.results.scan-results",
concatProblems(totalCounts),
results.size()));
setRootText(StringUtil.pluralize(
PylintBundle.message("plugin.results.scan-results",
concatProblems(totalCounts),
results.size()), results.size()));
} else {
setRootMessage("plugin.results.scan-no-results");
}
Expand All @@ -217,30 +219,40 @@ private Iterable<PsiFile> sortedFileNames(final Map<PsiFile, List<Problem>> resu

static String concatProblems(int[] problemCounts) {
StringBuilder violations = new StringBuilder();
if (problemCounts[SeverityLevel.FATAL.ordinal()] > 0) {
violations.append(PylintBundle.message("plugin.results.scan-results.fatal",
problemCounts[SeverityLevel.FATAL.ordinal()]));
int fatalCount = problemCounts[SeverityLevel.FATAL.ordinal()];
if (fatalCount > 0) {
violations.append(StringUtil.pluralize(
PylintBundle.message("plugin.results.scan-results.fatal", fatalCount),
fatalCount));
violations.append(' ');
}
if (problemCounts[SeverityLevel.ERROR.ordinal()] > 0) {
violations.append(PylintBundle.message("plugin.results.scan-results.error",
problemCounts[SeverityLevel.ERROR.ordinal()]));
violations.append(' ');
int errorsCount = problemCounts[SeverityLevel.ERROR.ordinal()];
if (errorsCount > 0) {
violations.append(StringUtil.pluralize(
PylintBundle.message("plugin.results.scan-results.error", errorsCount),
errorsCount));
violations.append(", ");
}
if (problemCounts[SeverityLevel.WARNING.ordinal()] > 0) {
violations.append(PylintBundle.message("plugin.results.scan-results.warning",
problemCounts[SeverityLevel.WARNING.ordinal()]));
violations.append(' ');
int warningCount = problemCounts[SeverityLevel.WARNING.ordinal()];
if (warningCount > 0) {
violations.append(StringUtil.pluralize(
PylintBundle.message("plugin.results.scan-results.warning", warningCount),
warningCount));
violations.append(", ");
}
if (problemCounts[SeverityLevel.CONVENTION.ordinal()] > 0) {
violations.append(PylintBundle.message("plugin.results.scan-results.convention",
problemCounts[SeverityLevel.CONVENTION.ordinal()]));
violations.append(' ');
int conventionCount = problemCounts[SeverityLevel.CONVENTION.ordinal()];
if (conventionCount > 0) {
violations.append(StringUtil.pluralize(
PylintBundle.message("plugin.results.scan-results.convention", conventionCount),
conventionCount));
violations.append(", ");
}
if (problemCounts[SeverityLevel.REFACTOR.ordinal()] > 0) {
violations.append(PylintBundle.message("plugin.results.scan-results.refactor",
problemCounts[SeverityLevel.REFACTOR.ordinal()]));
violations.append(' ');
int refactorCount = problemCounts[SeverityLevel.REFACTOR.ordinal()];
if (refactorCount > 0) {
violations.append(StringUtil.pluralize(
PylintBundle.message("plugin.results.scan-results.refactor", refactorCount),
refactorCount));
violations.append(", ");
}
return new String(violations.deleteCharAt(violations.length() - 2));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
]]></description>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="182.3911.36"/>
<idea-version since-build="145.258"/>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
Expand Down
114 changes: 8 additions & 106 deletions src/main/resources/com/leinardi/pycharm/pylint/PylintBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@ plugin.toolwindow.action=Scan
plugin.toolwindow.override=Rules:
plugin.toolwindow.default-file=<active configuration>
plugin.results.no-scan=No scan has been run as yet
plugin.results.no-rules-file=No rules file has been configured
plugin.results.rules-blacklist=The rules file is blacklisted for {0}s due to an error - you can use the ''Reload Rules file'' button to bypass this
plugin.results.in-progress=A scan is in progress
plugin.results.error=The scan failed due to an error - please see the event log \
for more information
plugin.results.error.missing-property=Please define the property ''{0}'' in \
the Pylint settings panel
plugin.results.error.instantiation-failed=The module {0} could not be loaded - \
please check you have added any prerequisites to the classpath
plugin.results.scan-no-results=Pylint found no problems in the file(s)
plugin.results.scan-results=Pylint found {0} in {1} file(s)
plugin.results.scan-results.fatal={0} fatal(s),
plugin.results.scan-results.error={0} error(s),
plugin.results.scan-results.warning={0} warning(s),
plugin.results.scan-results.convention={0} convention(s),
plugin.results.scan-results.refactor={0} refactor(s),
plugin.results.scan-no-results=Pylint found no problems
plugin.results.scan-results=Pylint found {0} in {1} file
plugin.results.scan-results.fatal={0} fatal
plugin.results.scan-results.error={0} error
plugin.results.scan-results.warning={0} warning
plugin.results.scan-results.convention={0} convention
plugin.results.scan-results.refactor={0} refactor
plugin.results.scan-file-result={0} : {1}
plugin.results.file-result={0} ({1}:{2}) [{3}]
plugin.results.unknown-source=unknown
Expand All @@ -49,124 +47,28 @@ plugin.status.aborted=Check was aborted
plugin.Pylint-PyCharm.description=<p>This plugin provides both real-time \
and on-demand scanning of Java files with Pylint from within the PyCharm \
IDE.</p>
plugin.debugging=The PyCharm classpath is inconsistent, which probably means we're debugging. The classpath will be parent-first, which will break some breaks in some circumstances.
plugin.update=<html>Pylint-PyCharm has been updated.<br><a href="https://github.com/leinardi/pylint-PyCharm-plugin/releases/tag/{0}">Release Notes</a></html>
plugin.notification.alerts=Pylint Alerts
plugin.notification.logging=Pylint Logging
plugin.exception=Unexpected Exception Caught
inspection.group=Pylint
inspection.display-name=Pylint real-time scan
inspection.message=Pylint: {0}
pylint.not-found.SuppressionFilter=<html>The Pylint suppression filter file was not found and will be ignored</html>
pylint.not-found.RegexpHeader=<html>The Pylint regexp header file was not found and will be ignored</html>
pylint.not-found.ImportControl=<html>The Pylint import control file was not found and will be ignored</html>
pylint.not-found.Header=<html>The Pylint header file was not found and will be ignored</html>
pylint.file-not-found=<html>The Pylint rules file could not be read</html>
pylint.file-io-failed=<html>The Pylint rules file could not be read</html>
pylint.configuration-disabled.file-not-found=<html>The current Pylint configuration has been disabled as the rules file is missing.</html>
pylint.checker-failed=<html><b>The Pylint rules file could not be loaded.</b><br>{0}<br>The file has been blacklisted for 60s.</html>
pylint.parse-failed=<html><b>The Pylint rules file could not be parsed.</b><br>{0}<br>The file has been blacklisted for 60s.</html>
pylint.could-not-read-properties=<html>Properties could not be read from the Pylint configuration file</html>
pylint.double-checked-locking=<html>The Pylint configuration file is not compatible with Pylint 5.6 or above.<br>Please remove the DoubleCheckingLocking check.</html>
pylint.exception=<html>The scan failed due to an exception: {0}</html>
pylint.exception-with-root-cause=<html><b>The scan failed due to an exception:<b> {0}<br><b>Root cause:</b><br>{1}</html>
config.pylint.path=Path to Pylint executable:
config.pylint.path.default=pylint
config.pylint.path.test=Test
config.pylint.path.success.message=Success: executable found!
config.pylint.path.failure.message=Failure: executable "{0}" not found
config.file.tab=Configuration File
config.file.description=The active rules file may be overridden, or deactivated, by module settings.
config.file.label.text=Configuration File:
config.url.label.text=Configuration URL:
config.file.xml.description=XML files (*.xml)
config.file.jar.description=Java Archive files (*.jar)
config.file.properties.table.0=Property Name
config.file.properties.table.1=Value
config.file.locations.table.0=Active
config.file.locations.table.1=Description
config.file.locations.table.2=File
config.file.add.text=Add
config.file.add.tooltip=Add a new configuration location
config.file.properties.text=Edit Properties
config.file.properties.tooltip=Edit the properties of the selected configuration
config.file.remove.text=Remove
config.file.remove.tooltip=Remove the selected configuration location
config.pylint.show-message-id=Show Pylint message ID in scan results
config.file.browse.text=Browse
config.file.browse.tooltip=Browse the file-system for Pylint executable
config.path.tab=Third-Party Checks
config.path.add.text=Add
config.path.add.tooltip=Add a new path element
config.path.edit.text=Edit
config.path.edit.tooltip=Edit an existing path element
config.path.remove.text=Remove
config.path.remove.tooltip=Remove a path element
config.path.move-up.text=Move Up
config.path.move-up.tooltip=Move a path element up in the list
config.path.move-down.text=Move Down
config.path.move-down.tooltip=Move a path element down in the list
config.csversion.labelText=Pylint version
config.scanscope.JavaOnly=Only Java sources (but not tests)
config.scanscope.JavaOnlyWithTests=Only Java sources (including tests)
config.scanscope.AllSources=All sources (but not tests)
config.scanscope.AllSourcesWithTests=All sources (including tests)
config.scanscope.Everything=All files in project
config.scanscope.labelText=Scan Scope
config.scanscope.tooltip=Choose which files should be scanned by Pylint
config.suppress-errors.checkbox.text=Treat Pylint errors as warnings
config.suppress-errors.checkbox.tooltip=If active then Pylint errors will not be marked as errors by PyCharm.
config.stabilize-classpath.text=Copy libraries from project directory (requires restart)
config.stabilize-classpath.tooltip=Prevents them from getting locked (slower)
config.inspection.description=Please use the Pylint item in the Settings \
dialogue to configure the inspection
config.file.okay.text=Finish
config.file.okay.tooltip=Commit your changes and close this window
config.file.next.text=Next
config.file.previous.text=Previous
config.file.previous.tooltip=Move to the previous step of the wizard
config.file.cancel.text=Cancel
config.file.cancel.tooltip=Abandon your changes and close this window
config.file.relative-file.text=Store relative to project location
config.file.relative-file.tooltip=The file path should be stored as relative to the project location.
config.file.insecure-http.text=Ignore invalid certificates
config.file.insecure-http.tooltip=Ignore invalid certificates. Caveat emptor.
config.file.file.text=Use a local Pylint file
config.file.file.label=File:
config.file.url.text=Use a Pylint file accessible via HTTP
config.file.url.label=URL:
config.file.classpath.text=Use a Pylint file accessible via the plugin classpath
config.file.classpath.label=File:
config.file.description.text=Description:
config.file.description.tooltip=A description of this configuration file
config.file.no-file=No location has been entered.
config.file.no-description=No description has been entered.
config.file.resolve-failed=The location could not be loaded:\n\n{0}
config.file.error.caption=Loading the rule file caused an error:
config.file.error.title=Error
config.file.error.duplicate.text=This location has already been added.
config.file.error.duplicate.title=Duplicate Location
config.file.complete.text=The rules file has been validated and is ready to add.
config.module.information=You can configure available files in the project configuration.
config.module.project-configuration.text=Use project configuration
config.module.project-configuration.tooltip=If selected then the project-level settings will be used for this module
config.module.module-configuration.text=Use a custom configuration
config.module.module-configuration.tooltip=If selected then the selected rules will be used for this module
config.module.exclude.text=Exclude this module from all checks
config.module.exclude.tooltip=If selected then no checks will be run against this module
config.module.module-file.text=Pylint Rules:
config.module.module-file.tooltip=The selected Pylint rules will be used for this module
action.PylintPluginActions=Close Pylint Window
action.PylintCurrentFileAction=Check Current File
action.PylintProjectFilesAction=Check Project
action.PylintScrollToSourceAction=Autoscroll to Source
action.PylintExpandAllAction=Expand All
action.PylintCollapseAllAction=Collapse All
handler.before.checkin.checkbox=Scan with Pylint
handler.before.checkin.error.text={0} files contain problems
handler.before.checkin.error.title=Pylint Scan
handler.before.checkin.error.review=Review
handler.before.checkin.scan.in-progress=Scanning...
handler.before.checkin.scan.text=Pylint is Scanning
error.no-config-file=No Pylint configuration file has been specified.
error.no-config-url=No Pylint configuration URL has been specified.
error.invalid-config-url=The configuration URL is invalid.

0 comments on commit b351480

Please sign in to comment.