Skip to content

Commit b00763a

Browse files
Localize UI strings and improve model actions
Replaced hardcoded UI strings with localized resource bundle lookups in controllers and FXML. Added new keys to messages.properties and messages_es.properties for model actions, download status, and error handling. Updated button styles to use atlantafx theme constants for consistency.
1 parent 22bdc94 commit b00763a

6 files changed

Lines changed: 63 additions & 20 deletions

File tree

src/main/java/com/org/ollamafx/controller/DownloadPopupController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void setDownloadTask(Task<Void> task) {
5656
}
5757

5858
public void setModelName(String modelName) {
59-
titleLabel.setText(com.org.ollamafx.App.getBundle().getString("download.title") + " " + modelName);
59+
titleLabel.setText(com.org.ollamafx.App.getBundle().getString("download.title.default") + " " + modelName);
6060
}
6161

6262
@FXML

src/main/java/com/org/ollamafx/controller/LocalModelsController.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.org.ollamafx.manager.ModelManager;
44
import com.org.ollamafx.model.OllamaModel;
5+
import atlantafx.base.theme.Styles;
56
import javafx.application.Platform;
67
import javafx.collections.ListChangeListener;
78
import javafx.fxml.FXML;
@@ -14,6 +15,9 @@
1415
import javafx.scene.layout.Region;
1516
import javafx.scene.layout.VBox;
1617

18+
import com.org.ollamafx.App;
19+
import java.text.MessageFormat;
20+
1721
import java.net.URL;
1822
import java.util.ResourceBundle;
1923

@@ -52,7 +56,7 @@ private void populateLocalModels() {
5256
modelListContainer.setSpacing(12);
5357

5458
if (modelManager == null || modelManager.getLocalModels().isEmpty()) {
55-
Label placeholder = new Label("No installed models found.");
59+
Label placeholder = new Label(App.getBundle().getString("local.empty"));
5660
placeholder.setStyle("-fx-text-fill: -color-fg-subtle; -fx-font-size: 14px;");
5761
modelListContainer.getChildren().add(placeholder);
5862
return;
@@ -92,8 +96,8 @@ private void populateLocalModels() {
9296
HBox.setHgrow(spacer, Priority.ALWAYS);
9397

9498
// Delete Action (Text Button, Apple Destructive Style)
95-
Button deleteBtn = new Button("Uninstall");
96-
deleteBtn.getStyleClass().add("apple-button-destructive");
99+
Button deleteBtn = new Button(App.getBundle().getString("model.action.uninstall"));
100+
deleteBtn.getStyleClass().add(Styles.DANGER);
97101

98102
deleteBtn.setOnAction(e -> confirmAndDelete(model));
99103

@@ -105,9 +109,11 @@ private void populateLocalModels() {
105109
private void confirmAndDelete(OllamaModel model) {
106110
javafx.scene.control.Alert alert = new javafx.scene.control.Alert(
107111
javafx.scene.control.Alert.AlertType.CONFIRMATION);
108-
alert.setTitle("Uninstall Model");
109-
alert.setHeaderText("Delete " + model.getName() + ":" + model.getTag() + "?");
110-
alert.setContentText("This action cannot be undone. The model files will be removed from your system.");
112+
alert.setTitle(App.getBundle().getString("local.uninstall.title"));
113+
String header = MessageFormat.format(App.getBundle().getString("local.uninstall.header"),
114+
model.getName() + ":" + model.getTag());
115+
alert.setHeaderText(header);
116+
alert.setContentText(App.getBundle().getString("local.uninstall.content"));
111117

112118
// Apply styling to dialog if we had a Utils method for it, or just rely on
113119
// default for now.

src/main/java/com/org/ollamafx/controller/ModelDetailController.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.org.ollamafx.manager.ModelManager;
55
import com.org.ollamafx.manager.OllamaManager;
66
import com.org.ollamafx.model.OllamaModel;
7+
import atlantafx.base.theme.Styles;
78

89
import javafx.animation.PauseTransition;
910
import javafx.application.Application;
@@ -74,7 +75,7 @@ private void showDownloadPopup(OllamaModel model) {
7475
Stage stage = new Stage();
7576
stage.initModality(Modality.APPLICATION_MODAL);
7677
stage.initStyle(StageStyle.TRANSPARENT);
77-
stage.setTitle("Downloading Model");
78+
stage.setTitle(App.getBundle().getString("download.title.default"));
7879

7980
Scene scene = new Scene(root);
8081
scene.setFill(Color.TRANSPARENT);
@@ -84,7 +85,7 @@ private void showDownloadPopup(OllamaModel model) {
8485
Task<Void> task = new Task<>() {
8586
@Override
8687
protected Void call() throws Exception {
87-
updateMessage("Starting download process...");
88+
updateMessage(App.getBundle().getString("download.status.process"));
8889
updateProgress(0, 100);
8990

9091
OllamaManager.getInstance().pullModel(model.getName(), model.getTag(),
@@ -107,7 +108,7 @@ protected Void call() throws Exception {
107108
String date = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")
108109
.format(LocalDateTime.now());
109110
OllamaModel newModel = new OllamaModel(
110-
model.getName(), "Installed locally", "N/A", model.getTag(),
111+
model.getName(), App.getBundle().getString("model.installed"), "N/A", model.getTag(),
111112
model.sizeProperty().get(), date,
112113
model.getContextLength(), model.getInputType());
113114
modelManager.addLocalModel(newModel);
@@ -140,8 +141,8 @@ protected Void call() throws Exception {
140141

141142
public void populateDetails(List<OllamaModel> modelTags) {
142143
if (modelTags == null || modelTags.isEmpty()) {
143-
modelNameLabel.setText("Error");
144-
modelDescriptionText.setText("Could not retrieve model details.");
144+
modelNameLabel.setText(App.getBundle().getString("model.error"));
145+
modelDescriptionText.setText(App.getBundle().getString("model.error.details"));
145146
modelListContainer.getChildren().clear();
146147
return;
147148
}
@@ -240,17 +241,17 @@ public void populateDetails(List<OllamaModel> modelTags) {
240241
&& modelManager.isModelInstalled(model.getName(), model.getTag());
241242

242243
if (isInstalled) {
243-
actionBtn.setText("Uninstall");
244-
actionBtn.getStyleClass().add("apple-button-destructive");
244+
actionBtn.setText(App.getBundle().getString("model.action.uninstall"));
245+
actionBtn.getStyleClass().add(Styles.DANGER);
245246
actionBtn.setOnAction(ev -> {
246247
if (modelManager != null) {
247248
modelManager.deleteModel(model.getName(), model.getTag());
248249
actionBtn.setDisable(true);
249250
}
250251
});
251252
} else {
252-
actionBtn.setText("Get"); // Apple Style "Get"
253-
actionBtn.getStyleClass().add("apple-button-action");
253+
actionBtn.setText(App.getBundle().getString("model.action.get")); // Apple Style "Get"
254+
actionBtn.getStyleClass().add(Styles.SUCCESS);
254255
actionBtn.setOnAction(ev -> {
255256
showDownloadPopup(model);
256257
});

src/main/resources/messages.properties

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,22 @@ local.title=Installed Models
7676
column.name=Name
7777
column.tag=Tag
7878
column.size=Size
79-
column.modified=Modified
79+
80+
# Local Models UI
81+
local.empty=No installed models found.
82+
local.uninstall.title=Uninstall Model
83+
local.uninstall.header=Delete {0}?
84+
local.uninstall.content=This action cannot be undone. The model files will be removed from your system.
85+
86+
# Download Status
87+
download.status.starting=Starting...
88+
download.status.downloading=Downloading...
89+
download.status.process=Starting download process...
90+
91+
# Model Details
92+
model.action.uninstall=Uninstall
93+
model.action.get=Get
94+
model.action.run=Run
95+
model.installed=Installed locally
96+
model.error=Error
97+
model.error.details=Could not retrieve model details

src/main/resources/messages_es.properties

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,22 @@ local.title=Modelos Instalados
7676
column.name=Nombre
7777
column.tag=Tag
7878
column.size=Tamaño
79-
column.modified=Modificado
79+
80+
# Local Models UI
81+
local.empty=No se encontraron modelos instalados.
82+
local.uninstall.title=Desinstalar Modelo
83+
local.uninstall.header=¿Eliminar {0}?
84+
local.uninstall.content=Esta acción no se puede deshacer. Los archivos del modelo serán eliminados de tu sistema.
85+
86+
# Download Status
87+
download.status.starting=Iniciando...
88+
download.status.downloading=Descargando...
89+
download.status.process=Iniciando proceso de descarga...
90+
91+
# Model Details
92+
model.action.uninstall=Desinstalar
93+
model.action.get=Obtener
94+
model.action.run=Ejecutar
95+
model.installed=Instalado localmente
96+
model.error=Error
97+
model.error.details=No se pudieron recuperar los detalles del modelo

src/main/resources/ui/download_popup.fxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
<VBox fx:id="rootPane" alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="420.0" spacing="25.0" styleClass="apple-dialog" stylesheets="@../css/ollama_active.css" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.org.ollamafx.controller.DownloadPopupController">
1515
<children>
16-
<Label fx:id="titleLabel" text="Downloading..." styleClass="apple-dialog-title" wrapText="true" textAlignment="CENTER"/>
16+
<Label fx:id="titleLabel" text="%download.title.default" styleClass="apple-dialog-title" wrapText="true" textAlignment="CENTER"/>
1717

1818
<atlantafx.base.controls.RingProgressIndicator fx:id="ringIndicator" progress="0.0" prefWidth="140.0" prefHeight="140.0"/>
1919

2020
<VBox alignment="CENTER" spacing="5.0">
2121
<children>
22-
<Label fx:id="statusLabel" text="Starting..." styleClass="apple-dialog-status-subtle"/>
22+
<Label fx:id="statusLabel" text="%download.status.starting" styleClass="apple-dialog-status-subtle"/>
2323
</children>
2424
</VBox>
2525

0 commit comments

Comments
 (0)