Skip to content

Commit

Permalink
internationalize some strings using copilot
Browse files Browse the repository at this point in the history
  • Loading branch information
manolo committed Jan 28, 2025
1 parent 3f0f00d commit 6bc8ff2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/main/frontend/themes/bakery/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
}
}

.app-name {
font-size:var(--lumo-font-size-xl);
font-weight:bold;
padding-left: 1em
}

.v-loading-indicator,
.v-system-error,
.v-reconnect-dialog {
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/vaadin/starter/bakery/ui/MainView.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.vaadin.starter.bakery.ui;

import static com.vaadin.flow.i18n.I18NProvider.translate;

import static com.vaadin.starter.bakery.ui.utils.BakeryConst.TITLE_DASHBOARD;
import static com.vaadin.starter.bakery.ui.utils.BakeryConst.TITLE_LOGOUT;
import static com.vaadin.starter.bakery.ui.utils.BakeryConst.TITLE_PRODUCTS;
Expand Down Expand Up @@ -52,7 +54,8 @@ public void init() {
confirmDialog.setCancelButtonTheme("raised tertiary");

this.setDrawerOpened(false);
Span appName = new Span("###Bakery###");
Span appName = new Span(translate("app.title"));
appName.addClassName("app-name");
appName.addClassName("hide-on-mobile");

menu = createMenuTabs();
Expand Down Expand Up @@ -150,4 +153,4 @@ private static <T extends HasComponents> T populateLink(T a, VaadinIcon icon, St
a.add(title);
return a;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.vaadin.starter.bakery.ui.views.admin.products;

import static com.vaadin.flow.i18n.I18NProvider.translate;

import com.vaadin.flow.component.crud.BinderCrudEditor;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.grid.Grid;
Expand Down Expand Up @@ -51,9 +53,9 @@ protected String getBasePage() {
}

private static BinderCrudEditor<Product> createForm() {
TextField name = new TextField("Product name");
TextField name = new TextField(translate("product.name"));
name.getElement().setAttribute("colspan", "2");
TextField price = new TextField("Unit price");
TextField price = new TextField(translate("unit.price"));
price.getElement().setAttribute("colspan", "2");

FormLayout form = new FormLayout(name, price);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.vaadin.starter.bakery.ui.views.admin.users;

import static com.vaadin.flow.i18n.I18NProvider.translate;

import jakarta.annotation.security.RolesAllowed;

import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -53,15 +55,15 @@ protected String getBasePage() {
}

private static BinderCrudEditor<User> createForm(PasswordEncoder passwordEncoder) {
EmailField email = new EmailField("Email (login)");
EmailField email = new EmailField(translate("email.field"));
email.getElement().setAttribute("colspan", "2");
TextField first = new TextField("First name");
TextField last = new TextField("Last name");
PasswordField password = new PasswordField("Password");
TextField first = new TextField(translate("first.name.field"));
TextField last = new TextField(translate("last.name.field"));
PasswordField password = new PasswordField(translate("password.field"));
password.getElement().setAttribute("colspan", "2");
ComboBox<String> role = new ComboBox<>();
role.getElement().setAttribute("colspan", "2");
role.setLabel("Role");
role.setLabel(translate("role.field"));

FormLayout form = new FormLayout(email, first, last, password, role);

Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/vaadin-i18n/translations.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
app.title=Bakery
product.name=Product name
unit.price=Unit price
email.field=Email (login)
first.name.field=First name
last.name.field=Last name
password.field=Password
role.field=Role

0 comments on commit 6bc8ff2

Please sign in to comment.