diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8c596a82..c7811122 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -11,7 +11,7 @@ jobs:
- run: sudo apt-get update
- run: sudo apt-get remove libunwind-14-dev
- run: sudo apt-get install -y build-essential gettext cmake valac libgee-0.8-dev libsqlite3-dev libgtk-4-dev libnotify-dev libgpgme-dev libsoup2.4-dev libgcrypt20-dev libqrencode-dev libnice-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libsrtp2-dev libadwaita-1-dev libsignal-protocol-c-dev libcanberra-dev
- - run: ./configure --release --no-debug --with-tests --enable-plugin=notification-sound --prefix=/usr --without-webrtc
+ - run: ./configure --release --no-debug --with-tests --enable-plugin=notification-sound --prefix=/usr --without-webrtc --enable-select-lang
- run: cmake --build build
- run: cmake --build build --target=test
- name: Build DEB-package
@@ -41,7 +41,7 @@ jobs:
- run: sudo apt-get update
- run: sudo apt-get remove libunwind-14-dev
- run: sudo apt-get install -y build-essential gettext libadwaita-1-dev libcanberra-dev libgcrypt20-dev libgee-0.8-dev libgpgme-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libgtk-4-dev libnice-dev libnotify-dev libqrencode-dev libsignal-protocol-c-dev libsoup2.4-dev libsqlite3-dev libsrtp2-dev meson valac
- - run: meson setup build -Duse-soup2=true -Dplugin-rtp-webrtc-audio-processing=disabled
+ - run: meson setup build -Duse-soup2=true -Dplugin-rtp-webrtc-audio-processing=disabled -Dselect-lang=enabled
- run: meson compile -C build
- run: meson test -C build
build-flatpak:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 99d81319..d212b13b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,7 @@ include(CTest)
option(PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING "Use WebRTC audio processing" ON)
option(WITH_WASAPI "Use wasapi instead of directsound on windows" ON)
+option(ENABLE_SELECT_LANG "Add language change to settings" OFF)
# https://gitlab.kitware.com/cmake/cmake/-/issues/19804
if (WIN32)
@@ -195,7 +196,11 @@ endif (NOT NO_DEBUG)
if (WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_POSIX_C_SOURCE=1")
set(CMAKE_VALA_FLAGS "${CMAKE_VALA_FLAGS} --define=_WIN32")
-endif(WIN32)
+endif (WIN32)
+
+if (ENABLE_SELECT_LANG)
+ set(CMAKE_VALA_FLAGS "${CMAKE_VALA_FLAGS} --define=ENABLE_SELECT_LANG")
+endif (ENABLE_SELECT_LANG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
diff --git a/build-win64.sh b/build-win64.sh
index f0c689af..b9e7f7b1 100644
--- a/build-win64.sh
+++ b/build-win64.sh
@@ -94,7 +94,7 @@ prepare()
configure_cmake()
{
msg "Running configuration for Windows"
- ./configure --program-prefix="$DIST_DIR" --no-debug --release --disable-fast-vapi --with-libsoup3 --with-tests
+ ./configure --program-prefix="$DIST_DIR" --no-debug --release --disable-fast-vapi --with-libsoup3 --with-tests --enable-select-lang
msg "Configured!"
}
@@ -125,6 +125,7 @@ configure_meson()
meson setup ${cmd} --prefix "$DIST_DIR" \
-D crypto-backend=${encr} \
-D plugin-ice=enabled \
+ -D select-lang=enabled \
$PROJ_DIR $BUILD_DIR
}
diff --git a/configure b/configure
index 24a13bc3..3289e53a 100755
--- a/configure
+++ b/configure
@@ -2,6 +2,7 @@
OPTS=`getopt -o "h" --long \
help,fetch-only,no-debug,disable-fast-vapi,with-tests,release,with-libsoup3,without-webrtcdsp,\
+enable-select-lang,\
enable-plugin:,disable-plugin:,\
prefix:,program-prefix:,exec-prefix:,lib-suffix:,\
bindir:,libdir:,includedir:,datadir:,\
@@ -18,6 +19,7 @@ DISABLED_PLUGINS=
BUILD_TESTS=no
BUILD_TYPE=Debug
DISABLE_FAST_VAPI=
+ENABLE_SELECT_LANG=no
LIB_SUFFIX=
NO_DEBUG=
USE_SOUP3=
@@ -52,6 +54,7 @@ Configuration:
builds (during development).
--fetch-only Only fetch the files required to run ./configure
without network access later and exit.
+ --enable-select-lang enable language switching for the settings menu
--no-debug Build without debug symbols
--release Configure to build an optimized release version
--with-libsoup3 Build with libsoup-3.0
@@ -113,6 +116,7 @@ while true; do
--with-libsoup3 ) USE_SOUP3=yes; shift ;;
--without-webrtcdsp ) PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING=no; shift ;;
--disable-fast-vapi ) DISABLE_FAST_VAPI=yes; shift ;;
+ --enable-select-lang) ENABLE_SELECT_LANG=yes; shift ;;
--no-debug ) NO_DEBUG=yes; shift ;;
--release ) BUILD_TYPE=RelWithDebInfo; shift ;;
--with-tests ) BUILD_TESTS=yes; shift ;;
@@ -223,6 +227,7 @@ cmake -G "$cmake_type" \
-DINCLUDE_INSTALL_DIR="$INCLUDEDIR" \
-DLIB_INSTALL_DIR="$LIBDIR" \
-DPLUGIN_RTP_WEBRTC_AUDIO_PROCESSING="$PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING" \
+ -DENABLE_SELECT_LANG="$ENABLE_SELECT_LANG" \
-Wno-dev \
.. || exit 9
diff --git a/libdino/src/application.vala b/libdino/src/application.vala
index 0fcee731..b66d928b 100644
--- a/libdino/src/application.vala
+++ b/libdino/src/application.vala
@@ -34,6 +34,10 @@ public interface Application : GLib.Application {
this.settings = new Dino.Entities.Settings.from_db(db);
this.stream_interactor = new StreamInteractor(db);
+#if ENABLE_SELECT_LANG
+ Environment.set_variable("LANGUAGE", settings.ui_language, true);
+#endif
+
MessageProcessor.start(stream_interactor, db);
MessageStorage.start(stream_interactor, db);
PresenceManager.start(stream_interactor);
diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala
index 8f39713f..07b98325 100644
--- a/libdino/src/entity/settings.vala
+++ b/libdino/src/entity/settings.vala
@@ -15,6 +15,7 @@ public class Settings : Object {
default_encryption = col_to_encryption_or_default("default_encryption", Encryption.UNKNOWN);
send_button = col_to_bool_or_default("send_button", false);
enter_newline = col_to_bool_or_default("enter_newline", false);
+ ui_language_ = col_to_string_or_default("ui_language", "en");
}
private bool col_to_bool_or_default(string key, bool def) {
@@ -28,6 +29,12 @@ public class Settings : Object {
return val != null ? Encryption.parse(val) : def;
}
+ private string col_to_string_or_default(string key, string def) {
+ var sval = db.settings.value;
+ string? val = db.settings.select({sval}).with(db.settings.key, "=", key)[sval];
+ return val != null ? val : def;
+ }
+
private bool send_typing_;
public bool send_typing {
get { return send_typing_; }
@@ -128,6 +135,19 @@ public class Settings : Object {
enter_newline_ = value;
}
}
+
+ private string ui_language_;
+ public string ui_language {
+ get { return ui_language_; }
+ set {
+ string valstr = value.to_string();
+ db.settings.upsert()
+ .value(db.settings.key, "ui_language", true)
+ .value(db.settings.value, valstr)
+ .perform();
+ ui_language_ = value;
+ }
+ }
}
}
diff --git a/main/data/settings_dialog.ui b/main/data/settings_dialog.ui
index 04bd548b..b9208abf 100644
--- a/main/data/settings_dialog.ui
+++ b/main/data/settings_dialog.ui
@@ -140,6 +140,25 @@
+
+
+
diff --git a/main/po/en.po b/main/po/en.po
index 7fb7fc6f..5ae2bf66 100644
--- a/main/po/en.po
+++ b/main/po/en.po
@@ -1024,6 +1024,14 @@ msgstr ""
msgid "Check spelling"
msgstr ""
+#: main/data/settings_dialog.ui:148
+msgid "Select language"
+msgstr ""
+
+#: main/data/settings_dialog.ui:149
+msgid "Application restart required"
+msgstr ""
+
#: main/data/im.dino.Dino.appdata.xml.in:7
msgid "Modern XMPP Chat Client"
msgstr ""
diff --git a/main/po/ru.po b/main/po/ru.po
index 2b3af4d1..07a59327 100644
--- a/main/po/ru.po
+++ b/main/po/ru.po
@@ -1040,6 +1040,14 @@ msgstr "Превращать смайлы в эмодзи"
msgid "Check spelling"
msgstr "Проверка орфографии"
+#: main/data/settings_dialog.ui:148
+msgid "Select language"
+msgstr "Выбор языка"
+
+#: main/data/settings_dialog.ui:149
+msgid "Application restart required"
+msgstr "Требуется перезапуск приложения"
+
#: main/data/im.dino.Dino.appdata.xml.in:7
msgid "Modern XMPP Chat Client"
msgstr "Современный XMPP клиент"
diff --git a/main/src/ui/settings_dialog.vala b/main/src/ui/settings_dialog.vala
index 5bdcee99..646e5149 100644
--- a/main/src/ui/settings_dialog.vala
+++ b/main/src/ui/settings_dialog.vala
@@ -15,6 +15,10 @@ class SettingsDialog : Adw.PreferencesWindow {
[GtkChild] private unowned CheckButton encryption_radio_openpgp;
[GtkChild] private unowned Switch send_button_switch;
[GtkChild] private unowned Switch enter_newline_switch;
+#if ENABLE_SELECT_LANG
+ [GtkChild] private unowned Adw.ComboRow select_lang_comborow;
+ [GtkChild] private unowned Adw.PreferencesGroup select_lang_group;
+#endif
Dino.Entities.Settings settings = Dino.Application.get_default().settings;
@@ -65,6 +69,21 @@ class SettingsDialog : Adw.PreferencesWindow {
enter_newline_switch.active = visible;
}
});
+
+#if ENABLE_SELECT_LANG
+ var lang_short_list = new Gee.ArrayList();
+ lang_short_list.add("en");
+ lang_short_list.add("ru");
+
+ select_lang_comborow.set_selected(lang_short_list.index_of(settings.ui_language));
+
+ select_lang_comborow.notify["selected-item"].connect(() => {
+ settings.ui_language = lang_short_list.get((int)select_lang_comborow.get_selected());
+ });
+
+ select_lang_group.visible = true;
+#endif
+
}
}
diff --git a/meson.build b/meson.build
index 6c7643e7..e25e5376 100644
--- a/meson.build
+++ b/meson.build
@@ -24,6 +24,10 @@ else
endforeach
endif
+if get_option('select-lang').allowed()
+ add_project_arguments('-D', 'ENABLE_SELECT_LANG', language: 'vala')
+endif
+
if get_option('crypto-backend') == 'auto'
# Prefer libgcrypt/gnutls over openssl because glib-networking is usually
# built with gnutls anyway.
diff --git a/meson_options.txt b/meson_options.txt
index b384cb41..22dc6070 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -17,3 +17,5 @@ option('plugin-rtp-webrtc-audio-processing', type: 'feature', description: 'Voic
option('use-soup2', type: 'boolean', value: false, description: 'Use libsoup version 2 instead of 3')
option('with-wasapi', type: 'boolean', value: true, description: 'Use wasapi insted of directsound on windows')
+
+option('select-lang', type: 'feature', value: 'disabled', description: 'Enable language change in settings')