Skip to content

Commit

Permalink
Merge pull request #4 from ryonakano/setup-l10n
Browse files Browse the repository at this point in the history
Setup l10n correctly
  • Loading branch information
sammarxz authored Feb 25, 2025
2 parents 25e01a4 + 8623b87 commit 6ef1f91
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 37 deletions.
24 changes: 12 additions & 12 deletions data/ui/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0"/>
<template class="PomerodePreferencesWindow" parent="AdwPreferencesWindow">
<property name="title">Preferences</property>
<property name="title" translatable="yes">Preferences</property>
<property name="default-width">400</property>
<property name="modal">true</property>
<child>
<object class="AdwPreferencesPage">
<child>
<object class="AdwPreferencesGroup">
<property name="title">Intervals</property>
<property name="title" translatable="yes">Intervals</property>

<!-- Work Duration -->
<child>
<object class="AdwActionRow">
<property name="title">Work Duration</property>
<property name="subtitle">Duration in minutes</property>
<property name="title" translatable="yes">Work Duration</property>
<property name="subtitle" translatable="yes">Duration in minutes</property>
<child>
<object class="GtkBox">
<property name="valign">center</property>
Expand Down Expand Up @@ -58,8 +58,8 @@
<!-- Break Duration -->
<child>
<object class="AdwActionRow">
<property name="title">Break Duration</property>
<property name="subtitle">Duration in minutes</property>
<property name="title" translatable="yes">Break Duration</property>
<property name="subtitle" translatable="yes">Duration in minutes</property>
<child>
<object class="GtkBox">
<property name="valign">center</property>
Expand Down Expand Up @@ -101,8 +101,8 @@
<!-- Long Break Duration -->
<child>
<object class="AdwActionRow">
<property name="title">Long Break Duration</property>
<property name="subtitle">Duration in minutes</property>
<property name="title" translatable="yes">Long Break Duration</property>
<property name="subtitle" translatable="yes">Duration in minutes</property>
<child>
<object class="GtkBox">
<property name="valign">center</property>
Expand Down Expand Up @@ -144,8 +144,8 @@
<!-- Intervals until Long Break -->
<child>
<object class="AdwActionRow">
<property name="title">Intervals until Long Break</property>
<property name="subtitle">Number of work intervals before a long break</property>
<property name="title" translatable="yes">Intervals until Long Break</property>
<property name="subtitle" translatable="yes">Number of work intervals before a long break</property>
<child>
<object class="GtkBox">
<property name="valign">center</property>
Expand Down Expand Up @@ -187,8 +187,8 @@
<!-- Autostart Intervals -->
<child>
<object class="AdwActionRow">
<property name="title">Autostart Intervals</property>
<property name="subtitle">Automatically start next interval when current one ends</property>
<property name="title" translatable="yes">Autostart Intervals</property>
<property name="subtitle" translatable="yes">Automatically start next interval when current one ends</property>
<child>
<object class="GtkSwitch" id="autostart_intervals_switch">
<property name="valign">center</property>
Expand Down
8 changes: 4 additions & 4 deletions data/ui/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<property name="vexpand">true</property>
<child>
<object class="GtkLabel" id="session_label">
<property name="label">Focus Time</property>
<property name="label" translatable="yes">Focus Time</property>
<style>
<class name="session-label"/>
</style>
Expand Down Expand Up @@ -70,7 +70,7 @@
<property name="margin-bottom">12</property>
<child>
<object class="GtkButton" id="start_button">
<property name="label">Start</property>
<property name="label" translatable="yes">Start</property>
<property name="hexpand">true</property>
<style>
<class name="play-button"/>
Expand All @@ -89,11 +89,11 @@
<menu id="primary_menu">
<section>
<item>
<attribute name="label">Preferences</attribute>
<attribute name="label" translatable="yes">Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
<item>
<attribute name="label">About Pomerode</attribute>
<attribute name="label" translatable="yes">About Pomerode</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
Expand Down
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ project('com.github.sammarxz.pomerode', ['c', 'vala'],

app_id = 'com.github.sammarxz.pomerode'

i18n = import('i18n')
gnome = import('gnome')

add_project_arguments(
Expand All @@ -12,6 +13,7 @@ add_project_arguments(
)

subdir('data')
subdir('po')
subdir('src')

# Compile schemas
Expand Down
11 changes: 7 additions & 4 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
data/com.github.sammarxz.desktop.in
data/com.github.sammarxz.metainfo.xml.in
data/com.github.sammarxz.gschema.xml
data/com.github.sammarxz.pomerode.desktop.in
data/com.github.sammarxz.pomerode.metainfo.xml
data/com.github.sammarxz.pomerode.gschema.xml
src/application.vala
src/main.vala
src/window.vala
src/window.ui
data/gtk/help-overlay.ui
data/ui/preferences.ui
data/ui/window.ui
2 changes: 1 addition & 1 deletion po/meson.build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
i18n.gettext('pomerode', preset: 'glib')
i18n.gettext(meson.project_name(), preset: 'glib')
6 changes: 3 additions & 3 deletions src/application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public class Pomerode.Application : Adw.Application {
copyright = "© 2024 @sammarxz",
license_type = Gtk.License.GPL_3_0,
website = "https://github.com/sammarxz/pomerode",
website_label = "Project Website",
comments = "A simple focus timer app",
translator_credits = "translator-credits",
website_label = _("Project Website"),
comments = _("A simple focus timer app"),
translator_credits = _("translator-credits"),
transient_for = this.active_window
};
about.present ();
Expand Down
4 changes: 4 additions & 0 deletions src/config.vala.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace Build {
public const string GETTEXT_PACKAGE = @GETTEXT_PACKAGE@;
public const string LOCALEDIR = @LOCALEDIR@;
}
4 changes: 4 additions & 0 deletions src/main.vala
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
int main (string[] args) {
Intl.setlocale (LocaleCategory.ALL, "");
Intl.bindtextdomain (Build.GETTEXT_PACKAGE, Build.LOCALEDIR);
Intl.bind_textdomain_codeset (Build.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (Build.GETTEXT_PACKAGE);

var app = new Pomerode.Application ();
return app.run (args);
Expand Down
15 changes: 13 additions & 2 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ pomerode_vala_args = [
# '--enable-experimental-non-null',
]

config_data = configuration_data()
config_data.set_quoted('GETTEXT_PACKAGE', meson.project_name())
config_data.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))

config_file = configure_file(
input: 'config.vala.in',
output: 'config.vala',
configuration: config_data
)

pomerode_vala_sources = files(
'main.vala',
'application.vala',
Expand All @@ -16,6 +26,7 @@ pomerode_vala_sources = files(
)

pomerode_sources = [
config_file,
pomerode_vala_sources,
# vapi_sources,
resources
Expand All @@ -31,9 +42,9 @@ pomerode_dependencies = [
]

executable(
meson.project_name(),
'pomerode',
pomerode_sources,
vala_args: pomerode_vala_args,
dependencies: pomerode_dependencies,
install: true,
)
)
22 changes: 11 additions & 11 deletions src/window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ public class Pomerode.Window : Adw.ApplicationWindow {
is_running = !is_running;
if (is_running) {
start_timer ();
start_button.label = "Pause";
start_button.label = _("Pause");
start_button.remove_css_class("play-button");
start_button.add_css_class("pause-button");
} else {
stop_timer ();
start_button.label = "Start";
start_button.label = _("Start");
start_button.remove_css_class("pause-button");
start_button.add_css_class("play-button");
}
Expand Down Expand Up @@ -126,7 +126,7 @@ public class Pomerode.Window : Adw.ApplicationWindow {

if (autostart_intervals) {
start_timer ();
start_button.label = "Pause";
start_button.label = _("Pause");
start_button.remove_css_class ("play-button");
start_button.add_css_class ("pause-button");
is_running = true;
Expand All @@ -136,13 +136,13 @@ public class Pomerode.Window : Adw.ApplicationWindow {
private string get_completion_message () {
switch (current_session) {
case SessionType.FOCUS:
return "Focus session complete. Time for a break!";
return _("Focus session complete. Time for a break!");
case SessionType.SHORT_BREAK:
return "Break complete. Back to focus!";
return _("Break complete. Back to focus!");
case SessionType.LONG_BREAK:
return "Long break complete. Ready for a new cycle?";
return _("Long break complete. Ready for a new cycle?");
default:
return "Session complete!";
return _("Session complete!");
}
}

Expand Down Expand Up @@ -176,7 +176,7 @@ public class Pomerode.Window : Adw.ApplicationWindow {

update_label ();
update_session_label ();
start_button.label = "Start";
start_button.label = _("Start");
start_button.remove_css_class("pause-button");
start_button.add_css_class("play-button");
is_running = false;
Expand All @@ -191,13 +191,13 @@ public class Pomerode.Window : Adw.ApplicationWindow {
private void update_session_label () {
switch (current_session) {
case SessionType.FOCUS:
session_label.label = "Focus Time";
session_label.label = _("Focus Time");
break;
case SessionType.SHORT_BREAK:
session_label.label = "Short Break";
session_label.label = _("Short Break");
break;
case SessionType.LONG_BREAK:
session_label.label = "Long Break";
session_label.label = _("Long Break");
break;
}
}
Expand Down

0 comments on commit 6ef1f91

Please sign in to comment.