Skip to content

Commit

Permalink
🌐 add internationalization closes 29
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Fihlon <[email protected]>
  • Loading branch information
McPringle committed Mar 30, 2024
1 parent 1e95c61 commit 4bae23c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
4 changes: 4 additions & 0 deletions frontend/themes/apus/views/session-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@
.empty-session {
opacity: 0.5;
}

.empty-session h3 {
text-transform: uppercase;
}
13 changes: 6 additions & 7 deletions src/main/java/swiss/fihlon/apus/ui/view/ConferenceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ConferenceView(@NotNull final ConferenceService conferenceService,
@Override
protected void onAttach(@NotNull final AttachEvent attachEvent) {
setId("conference-view");
add(new H2(String.format("Rooms & Sessions (%s)",
add(new H2(String.format(getTranslation("conference.heading"),
LocalDate.now().getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.getDefault()))));
add(createLegend());
add(sessionContainer);
Expand All @@ -79,8 +79,7 @@ private void updateConferenceSessions() {
final var roomsWithSessions = conferenceService.getRoomsWithSessions().entrySet();
for (final Map.Entry<String, List<Session>> roomWithSession : roomsWithSessions) {
if (roomCounter.get() >= MAX_ROOMS_IN_VIEW) {
Notification.show(String.format("Too many rooms (%d) to display, no more space left on screen!",
roomsWithSessions.size()));
Notification.show(String.format(getTranslation("conference.error.rooms"), roomsWithSessions.size()));
break;
}
final SessionView sessionView = createSessionView(roomWithSession, today, roomCounter);
Expand All @@ -89,16 +88,16 @@ private void updateConferenceSessions() {
}

@NotNull
private static Component createLegend() {
final Component runningSession = new Span("running session");
private Component createLegend() {
final Component runningSession = new Span(getTranslation("conference.legend.running-session"));
runningSession.getElement().getThemeList().add(LABEL_THEME);
runningSession.addClassName("running-session");

final Component nextSession = new Span("next session");
final Component nextSession = new Span(getTranslation("conference.legend.next-session"));
nextSession.getElement().getThemeList().add(LABEL_THEME);
nextSession.addClassName("next-session");

final Component emptySession = new Span("room closed");
final Component emptySession = new Span(getTranslation("conference.legend.empty-session"));
emptySession.getElement().getThemeList().add(LABEL_THEME);
emptySession.addClassName("empty-session");

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/swiss/fihlon/apus/ui/view/SessionView.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected void onAttach(@NotNull final AttachEvent attachEvent) {

@NotNull
private Component createTitleComponent() {
return new H3(new Text(title == null ? "CLOSED" : title));
return new H3(new Text(title == null ? getTranslation("conference.session.closed") : title));
}
@NotNull
private Component createSpeakersComponent() {
Expand Down Expand Up @@ -111,8 +111,8 @@ private Component createTimeComponent() {
} else if (startTime.isBefore(now) && endTime.isAfter(now)) { // running session
final Duration duration = Duration.between(now, endTime);
final long timeLeft = Math.round(duration.getSeconds() / 60f);
final String timeUnit = timeLeft == 1 ? "minute" : "minutes";
timeComponent.add(new Text(String.format("⌛ %d %s left", timeLeft, timeUnit)));
final String timeText = getTranslation(timeLeft == 1 ? "conference.session.countdown.singular" : "conference.session.countdown.plural");
timeComponent.add(new Text("⌛ " + String.format(timeText, timeLeft)));
addClassName("running-session");
} else { // next session
timeComponent.add(new Text(String.format("⌚ %s - %s", startTime, endTime)));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/swiss/fihlon/apus/ui/view/SocialView.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public SocialView(@NotNull final SocialService socialService,
@Override
protected void onAttach(@NotNull final AttachEvent attachEvent) {
setId("social-view");
add(new H2(String.format("Posts with #%s on Mastodon", configuration.getMastodon().hashtag())));
add(new H2(String.format(getTranslation("social.heading"), configuration.getMastodon().hashtag())));
add(messageContainer);
messageContainer.addClassName("masonry");
updateMessages();
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/vaadin-i18n/translations.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
conference.heading=Rooms & Sessions (%s)
conference.legend.running-session=running session
conference.legend.next-session=next session
conference.legend.empty-session=room closed
conference.session.countdown.singular=%d minute left
conference.session.countdown.plural=%d minutes left
conference.session.closed=closed
conference.error.rooms=Too many rooms (%d) to display, no more space left on screen!
social.heading=Posts with #%s on Mastodon

0 comments on commit 4bae23c

Please sign in to comment.