feat: use textarea component for translation dialog locale values

Resolves #477
This commit is contained in:
marhali 2025-09-06 12:49:22 +02:00
parent 0badd8a1c6
commit 0d1afad9e5
3 changed files with 16 additions and 6 deletions

View File

@ -4,6 +4,10 @@
## [Unreleased] ## [Unreleased]
### Changed
- Use textarea component for translation dialog locale values (#477)
## [4.8.1] - 2025-09-04 ## [4.8.1] - 2025-09-04
### Changed ### Changed

View File

@ -4,7 +4,7 @@ pluginGroup = de.marhali.easyi18n
pluginName = easy-i18n pluginName = easy-i18n
pluginRepositoryUrl = https://github.com/marhali/easy-i18n pluginRepositoryUrl = https://github.com/marhali/easy-i18n
# SemVer format -> https://semver.org # SemVer format -> https://semver.org
pluginVersion = 4.8.1 pluginVersion = 4.9.0
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 242 pluginSinceBuild = 242

View File

@ -3,6 +3,7 @@ package de.marhali.easyi18n.dialog;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.components.JBTextArea;
import com.intellij.ui.components.JBTextField; import com.intellij.ui.components.JBTextField;
import com.intellij.util.Consumer; import com.intellij.util.Consumer;
import com.intellij.util.ui.FormBuilder; import com.intellij.util.ui.FormBuilder;
@ -38,7 +39,7 @@ abstract class TranslationDialog extends DialogWrapper {
protected final @NotNull Translation origin; protected final @NotNull Translation origin;
protected final JTextField keyField; protected final JTextField keyField;
protected final Map<String, JTextField> localeValueFields; protected final Map<String, JTextArea> localeValueFields;
private final Set<Consumer<TranslationUpdate>> callbacks; private final Set<Consumer<TranslationUpdate>> callbacks;
@ -64,7 +65,12 @@ abstract class TranslationDialog extends DialogWrapper {
this.localeValueFields = new HashMap<>(); this.localeValueFields = new HashMap<>();
for(String locale : InstanceManager.get(project).store().getData().getLocales()) { for(String locale : InstanceManager.get(project).store().getData().getLocales()) {
localeValueFields.put(locale, new JBTextField(value != null ? value.get(locale) : null)); var field = new JBTextArea(value != null ? value.get(locale) : null, 1, 1);
field.setLineWrap(true);
field.setWrapStyleWord(true);
field.setBorder(BorderFactory.createTitledBorder(locale));
localeValueFields.put(locale, field);
} }
} }
@ -114,7 +120,7 @@ abstract class TranslationDialog extends DialogWrapper {
TranslationValue value = new TranslationValue(); TranslationValue value = new TranslationValue();
for(Map.Entry<String, JTextField> entry : localeValueFields.entrySet()) { for(Map.Entry<String, JTextArea> entry : localeValueFields.entrySet()) {
value.put(entry.getKey(), entry.getValue().getText()); value.put(entry.getKey(), entry.getValue().getText());
} }
@ -136,8 +142,8 @@ abstract class TranslationDialog extends DialogWrapper {
private JComponent createLocalesPanel() { private JComponent createLocalesPanel() {
FormBuilder builder = FormBuilder.createFormBuilder(); FormBuilder builder = FormBuilder.createFormBuilder();
for(Map.Entry<String, JTextField> localeEntry : localeValueFields.entrySet()) { for(Map.Entry<String, JTextArea> localeEntry : localeValueFields.entrySet()) {
builder.addLabeledComponent(localeEntry.getKey(), localeEntry.getValue(), 6, true); builder.addComponent(localeEntry.getValue(), 6);
} }
JScrollPane scrollPane = new JBScrollPane(builder.getPanel()); JScrollPane scrollPane = new JBScrollPane(builder.getPanel());