Skip to content

Extracting existing messages into bundle #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions resources/magento2/validation.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ validator.notEmpty={0} must not be empty
validator.package.validPath=Please specify a valid Magento 2 installation path
validator.alphaNumericCharacters={0} must contain letters and numbers only
validator.startWithNumberOrCapitalLetter={0} must start from a number or a capital letter
validator.onlyNumbers={0} must contain numbers only
validator.identifier={0} must contain letters, numbers, dashes, and underscores only
validator.directory.isNotValid={0} is not valid
validator.module.noSuchModule=No such module {0}
validator.file.alreadyExists={0} already exists
validator.file.cantBeCreated={0} can't be created
validator.class.alreadyDeclared={0} already declared in the target module
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
import com.magento.idea.magento2plugin.magento.packages.Package;
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
import com.magento.idea.magento2plugin.validators.ValidatorBundle;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.event.*;
Expand Down Expand Up @@ -123,7 +124,9 @@ private void onOK() {
getPreferenceArea()
), project).generate(OverrideClassByAPreferenceAction.ACTION_NAME);
if (diXml == null) {
JOptionPane.showMessageDialog(null, "Preference already declared in the target module!", "Error", JOptionPane.ERROR_MESSAGE);
String errorMessage = ValidatorBundle.message("validator.class.alreadyDeclared", "Preference");
JOptionPane.showMessageDialog(null, errorMessage, "Error", JOptionPane.ERROR_MESSAGE);

return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public boolean validate(Project project)
}

if (!pluginName.matches(Regex.IDENTIFIER)) {
JOptionPane.showMessageDialog(null, "Plugin Name must contain letters, numbers, dashes, and underscores only.", errorTitle, JOptionPane.ERROR_MESSAGE);
String errorMessage = ValidatorBundle.message("validator.identifier", "Plugin Name");
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);

return false;
}

Expand All @@ -88,7 +90,9 @@ public boolean validate(Project project)
}

if (!sortOrder.matches(Regex.NUMERIC)) {
JOptionPane.showMessageDialog(null, "Sort Order must contain numbers only.", errorTitle, JOptionPane.ERROR_MESSAGE);
String errorMessage = ValidatorBundle.message("validator.onlyNumbers", "Sort Order");
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);

return false;
}

Expand All @@ -102,7 +106,9 @@ public boolean validate(Project project)

List<String> allModulesList = ModuleIndex.getInstance(project).getEditableModuleNames();
if (!allModulesList.contains(pluginModule)) {
JOptionPane.showMessageDialog(null, "No such module '".concat(pluginModule).concat("'."), errorTitle, JOptionPane.ERROR_MESSAGE);
String errorMessage = ValidatorBundle.message("validator.module.noSuchModule", pluginModule);
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,16 @@ public boolean validate(Project project)
}

if (!preferenceClassName.matches(Regex.ALPHANUMERIC)) {
JOptionPane.showMessageDialog(null, "Preference Class Name must contain letters and numbers only.", errorTitle, JOptionPane.ERROR_MESSAGE);
String errorMessage = ValidatorBundle.message("validator.alphaNumericCharacters", "Preference Class");
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);

return false;
}

if (!Character.isUpperCase(preferenceClassName.charAt(0)) && !Character.isDigit(preferenceClassName.charAt(0))) {
JOptionPane.showMessageDialog(null, "Preference Class Name must start from a number or a capital letter", errorTitle, JOptionPane.ERROR_MESSAGE);
String errorMessage = ValidatorBundle.message("validator.startWithNumberOrCapitalLetter", "Preference Class");
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);

return false;
}

Expand Down