Skip to content

Commit c6b424a

Browse files
committed
Extract localized strings to a resource bundle
1 parent 623252a commit c6b424a

21 files changed

+174
-44
lines changed

resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<name>Nette Tester</name>
44
<version>1.0.0-alpha.4</version>
55
<vendor email="[email protected]" url="https://jiripudil.cz">Jiří Pudil</vendor>
6+
<resource-bundle>messages.TesterBundle</resource-bundle>
67

78
<description><![CDATA[
89
<a href="https://github.com/jiripudil/intellij-nette-tester">Github</a>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
action.generateSetupMethod.name=TestCase setUp() method
2+
action.generateSetupMethod.description=Creates a TestCase setUp() method
3+
4+
action.generateTeardownMethod.name=TestCase tearDown() method
5+
action.generateTeardownMethod.description=Creates a TestCase tearDown() method
6+
7+
action.generateTestMethod.name=TestCase test() Method
8+
action.generateTestMethod.description=Creates a TestCase test() method
9+
10+
action.newTestCase.name=Nette Tester TestCase
11+
action.newTestCase.description=Creates a new Nette Tester TestCase
12+
13+
dialog.newTestCase.title=Create Nette Tester Test
14+
dialog.newTestCase.completionShortcut=Use {0} for {1} completion
15+
dialog.newTestCase.label.classToTest=Class to Test:
16+
dialog.newTestCase.label.testClass=Test name:
17+
dialog.newTestCase.label.namespace=Namespace:
18+
dialog.newTestCase.label.fileName=File name:
19+
dialog.newTestCase.label.directory=Directory:
20+
21+
configurationType.displayName=Nette Tester
22+
configurationType.description=Run tests via Nette Tester
23+
24+
runConfiguration.errors.phpExecutableNotFound=PHP executable not found.
25+
runConfiguration.errors.noTestScope=You must specify the test scope.
26+
runConfiguration.errors.testScopeNotFound=File or directory set as the test scope was not found.
27+
runConfiguration.errors.testEnvInterpreterNotFound=Test environment PHP interpreter not found.
28+
runConfiguration.errors.testEnvExecutableNotFound=Test environment PHP executable not found.
29+
runConfiguration.errors.noExecutable=You must specify path to Tester executable.
30+
runConfiguration.errors.executableNotFound=Tester executable was not found at given path.
31+
runConfiguration.errors.phpIniNotFound=The php.ini file was not found at given path.
32+
runConfiguration.errors.setupScriptNotFound=The setup script file was not found at given path.
33+
34+
runConfiguration.editor.tester.title=Nette Tester
35+
runConfiguration.editor.tester.testScope=Test scope:
36+
runConfiguration.editor.tester.testerExecutable=Tester executable:
37+
runConfiguration.editor.tester.testerOptions=Tester options:
38+
runConfiguration.editor.tester.setupScript=Setup script:
39+
40+
runConfiguration.editor.testEnv.title=Test Environment
41+
runConfiguration.editor.testEnv.interpreter=Interpreter:
42+
runConfiguration.editor.testEnv.interpreterOptions=Interpreter options:
43+
runConfiguration.editor.testEnv.phpIni=Path to php.ini
44+
runConfiguration.editor.testEnv.useSystemPhpIni=Use system php.ini
45+
46+
runConfiguration.editor.cli.title=Command Line
47+
runConfiguration.editor.cli.interpreterOptions=Interpreter options:
48+
runConfiguration.editor.cli.workingDirectory=Custom working directory:
49+
50+
settings.defaultExtension=Default extension:
51+
settings.namespaceMappings.title=Namespace mappings
52+
settings.namespaceMappings.noMappings=No mappings
53+
settings.namespaceMappings.sourceNamespace=Source namespace
54+
settings.namespaceMappings.testsNamespace=Tests namespace
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package cz.jiripudil.intellij.nette.tester;
2+
3+
import com.intellij.CommonBundle;
4+
import org.jetbrains.annotations.NonNls;
5+
import org.jetbrains.annotations.NotNull;
6+
import org.jetbrains.annotations.PropertyKey;
7+
8+
import java.util.ResourceBundle;
9+
10+
public class TesterBundle {
11+
@NonNls private static final String BUNDLE_NAME = "messages.TesterBundle";
12+
@NotNull private static final ResourceBundle BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
13+
14+
private TesterBundle() {
15+
}
16+
17+
public static String message(@PropertyKey(resourceBundle = BUNDLE_NAME) String key, Object... params) {
18+
return CommonBundle.message(BUNDLE, key, params);
19+
}
20+
}

src/cz/jiripudil/intellij/nette/tester/codeGeneration/TesterGenerateSetupMethodAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
import com.intellij.codeInsight.template.TemplateManager;
55
import com.intellij.openapi.editor.Editor;
66
import com.intellij.openapi.project.Project;
7+
import cz.jiripudil.intellij.nette.tester.TesterBundle;
78
import org.jetbrains.annotations.NotNull;
89

910
public class TesterGenerateSetupMethodAction extends TesterAbstractGenerateMethodAction {
1011
public TesterGenerateSetupMethodAction() {
11-
getTemplatePresentation().setText("TestCase setUp() method");
12-
getTemplatePresentation().setDescription("Creates a Nette Tester setUp() method");
12+
getTemplatePresentation().setText(TesterBundle.message("action.generateSetupMethod.name"));
13+
getTemplatePresentation().setDescription(TesterBundle.message("action.generateSetupMethod.description"));
1314
}
1415

1516
@Override

src/cz/jiripudil/intellij/nette/tester/codeGeneration/TesterGenerateTeardownMethodAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
import com.intellij.codeInsight.template.TemplateManager;
55
import com.intellij.openapi.editor.Editor;
66
import com.intellij.openapi.project.Project;
7+
import cz.jiripudil.intellij.nette.tester.TesterBundle;
78
import org.jetbrains.annotations.NotNull;
89

910
public class TesterGenerateTeardownMethodAction extends TesterAbstractGenerateMethodAction {
1011
public TesterGenerateTeardownMethodAction() {
11-
getTemplatePresentation().setText("TestCase tearDown() method");
12-
getTemplatePresentation().setDescription("Creates a Nette Tester tearDown() method");
12+
getTemplatePresentation().setText(TesterBundle.message("action.generateTeardownMethod.name"));
13+
getTemplatePresentation().setDescription(TesterBundle.message("action.generateTeardownMethod.description"));
1314
}
1415

1516
@Override

src/cz/jiripudil/intellij/nette/tester/codeGeneration/TesterGenerateTestMethodAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
import com.jetbrains.php.config.PhpLanguageFeature;
1010
import com.jetbrains.php.config.PhpLanguageLevel;
1111
import com.jetbrains.php.config.PhpProjectConfigurationFacade;
12+
import cz.jiripudil.intellij.nette.tester.TesterBundle;
1213
import org.jetbrains.annotations.NotNull;
1314

1415
public class TesterGenerateTestMethodAction extends TesterAbstractGenerateMethodAction {
1516
public TesterGenerateTestMethodAction() {
16-
getTemplatePresentation().setText("TestCase test method");
17-
getTemplatePresentation().setDescription("Creates a Nette Tester test method");
17+
getTemplatePresentation().setText(TesterBundle.message("action.generateTestMethod.name"));
18+
getTemplatePresentation().setDescription(TesterBundle.message("action.generateTestMethod.description"));
1819
}
1920

2021
@Override

src/cz/jiripudil/intellij/nette/tester/codeGeneration/TesterNewTestCaseAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
import com.jetbrains.php.PhpIcons;
77
import com.jetbrains.php.actions.PhpNewBaseAction;
88
import com.jetbrains.php.templates.PhpCreateFileFromTemplateDataProvider;
9+
import cz.jiripudil.intellij.nette.tester.TesterBundle;
910
import org.jetbrains.annotations.NotNull;
1011
import org.jetbrains.annotations.Nullable;
1112

1213
public class TesterNewTestCaseAction extends PhpNewBaseAction {
1314
public TesterNewTestCaseAction() {
14-
super("Nette Tester TestCase", "Creates a new Nette Tester TestCase", PhpIcons.PHP_TEST_FILE);
15+
super(TesterBundle.message("action.newTestCase.name"), TesterBundle.message("action.newTestCase.description"), PhpIcons.PHP_TEST_FILE);
1516
}
1617

1718
@Nullable

src/cz/jiripudil/intellij/nette/tester/codeGeneration/TesterNewTestCaseDialog.form

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<properties/>
1717
<border type="none"/>
1818
<children>
19-
<component id="5eb3e" class="javax.swing.JLabel">
19+
<component id="5eb3e" class="com.intellij.ui.components.JBLabel" binding="classToTestLabel" custom-create="true">
2020
<constraints>
2121
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
2222
</constraints>
@@ -51,7 +51,7 @@
5151
</constraints>
5252
<properties/>
5353
</component>
54-
<component id="3618d" class="javax.swing.JLabel">
54+
<component id="3618d" class="com.intellij.ui.components.JBLabel" binding="testClassLabel" custom-create="true">
5555
<constraints>
5656
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
5757
</constraints>
@@ -67,7 +67,7 @@
6767
</constraints>
6868
<properties/>
6969
</component>
70-
<component id="9cc43" class="javax.swing.JLabel">
70+
<component id="9cc43" class="com.intellij.ui.components.JBLabel" binding="namespaceLabel" custom-create="true">
7171
<constraints>
7272
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
7373
</constraints>
@@ -96,7 +96,7 @@
9696
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
9797
</constraints>
9898
</vspacer>
99-
<component id="d8d4c" class="javax.swing.JLabel">
99+
<component id="d8d4c" class="com.intellij.ui.components.JBLabel" binding="fileNameLabel" custom-create="true">
100100
<constraints>
101101
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
102102
</constraints>
@@ -112,7 +112,7 @@
112112
</constraints>
113113
<properties/>
114114
</component>
115-
<component id="3b105" class="javax.swing.JLabel">
115+
<component id="3b105" class="com.intellij.ui.components.JBLabel" binding="directoryLabel" custom-create="true">
116116
<constraints>
117117
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
118118
</constraints>

src/cz/jiripudil/intellij/nette/tester/codeGeneration/TesterNewTestCaseDialog.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.jetbrains.php.roots.ui.PhpNamespaceComboBox;
2323
import com.jetbrains.php.roots.ui.PhpPsrDirectoryComboBox;
2424
import com.jetbrains.php.ui.PhpUiUtil;
25+
import cz.jiripudil.intellij.nette.tester.TesterBundle;
2526
import cz.jiripudil.intellij.nette.tester.projectSettings.TesterProjectSettings;
2627
import cz.jiripudil.intellij.nette.tester.projectSettings.TesterProjectSettingsManager;
2728
import org.jetbrains.annotations.NotNull;
@@ -45,6 +46,12 @@ public class TesterNewTestCaseDialog extends PhpBaseNewClassDialog {
4546
private PhpPsrDirectoryComboBox directoryComboBox;
4647
private JBLabel directoryCompletionHint;
4748

49+
private JBLabel classToTestLabel;
50+
private JBLabel testClassLabel;
51+
private JBLabel namespaceLabel;
52+
private JBLabel fileNameLabel;
53+
private JBLabel directoryLabel;
54+
4855
TesterNewTestCaseDialog(@NotNull Project project, @Nullable PsiDirectory directory, @Nullable PsiFile file) {
4956
super(project, directory);
5057
this.init(contentPane, nameTextField, namespaceComboBox, namespaceCompletionHint, fileNameTextField, directoryComboBox, directoryCompletionHint);
@@ -72,9 +79,9 @@ public void documentChanged(DocumentEvent e) {
7279
PhpCompletionUtil.installClassCompletion(testTargetTextField, null, this.getDisposable());
7380

7481
String codeCompletionShortcut = PhpUiUtil.getShortcutTextByActionName("CodeCompletion");
75-
testTargetCompletionHint.setText("Use " + codeCompletionShortcut + " for class reference completion");
76-
namespaceCompletionHint.setText("Use " + codeCompletionShortcut + " for namespace completion");
77-
directoryCompletionHint.setText("Use " + codeCompletionShortcut + " for path completion");
82+
testTargetCompletionHint.setText(TesterBundle.message("dialog.newTestCase.completionShortcut", codeCompletionShortcut, "class reference"));
83+
namespaceCompletionHint.setText(TesterBundle.message("dialog.newTestCase.completionShortcut", codeCompletionShortcut, "namespace"));
84+
directoryCompletionHint.setText(TesterBundle.message("dialog.newTestCase.completionShortcut", codeCompletionShortcut, "path"));
7885

7986
this.addUpdateRequest(() -> {
8087
PhpClass phpClass = TesterTestCreator.findClass(file);
@@ -97,7 +104,7 @@ public void documentChanged(DocumentEvent e) {
97104
@Override
98105
protected void init() {
99106
super.init();
100-
this.setTitle("Create Nette Tester TestCase");
107+
this.setTitle(TesterBundle.message("dialog.newTestCase.title"));
101108
}
102109

103110
@Nullable
@@ -160,6 +167,12 @@ public void init(@NotNull VirtualFile baseDir, @NotNull String namespace) {
160167
}
161168
};
162169

170+
classToTestLabel = new JBLabel(TesterBundle.message("dialog.newTestCase.label.classToTest"));
171+
testClassLabel = new JBLabel(TesterBundle.message("dialog.newTestCase.label.testClass"));
172+
namespaceLabel = new JBLabel(TesterBundle.message("dialog.newTestCase.label.namespace"));
173+
fileNameLabel = new JBLabel(TesterBundle.message("dialog.newTestCase.label.fileName"));
174+
directoryLabel = new JBLabel(TesterBundle.message("dialog.newTestCase.label.directory"));
175+
163176
testTargetCompletionHint = new JBLabel(UIUtil.ComponentStyle.MINI);
164177
namespaceCompletionHint = new JBLabel(UIUtil.ComponentStyle.MINI);
165178
directoryCompletionHint = new JBLabel(UIUtil.ComponentStyle.MINI);

src/cz/jiripudil/intellij/nette/tester/configuration/TesterConfigurationType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import com.intellij.execution.configurations.ConfigurationTypeBase;
44
import com.intellij.execution.configurations.ConfigurationTypeUtil;
55
import com.jetbrains.php.PhpIcons;
6+
import cz.jiripudil.intellij.nette.tester.TesterBundle;
67

78
public class TesterConfigurationType extends ConfigurationTypeBase {
89
protected TesterConfigurationType() {
9-
super("nette-tester", "Nette Tester", "Run tests via Nette Tester", PhpIcons.PHP_TEST_FILE);
10+
super("nette-tester", TesterBundle.message("configurationType.displayName"), TesterBundle.message("configurationType.description"), PhpIcons.PHP_TEST_FILE);
1011
this.addFactory(new TesterConfigurationFactory(this));
1112
}
1213

0 commit comments

Comments
 (0)