Added language change in settings

Signed-off-by: Maxim Logaev <maxlogaev@proton.me>
This commit is contained in:
Maxim Logaev 2024-04-24 15:39:55 +03:00
parent 863cbfb53a
commit 4f7809dd6c
12 changed files with 99 additions and 4 deletions

View file

@ -11,7 +11,7 @@ jobs:
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get remove libunwind-14-dev - 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: 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
- run: cmake --build build --target=test - run: cmake --build build --target=test
- name: Build DEB-package - name: Build DEB-package
@ -41,7 +41,7 @@ jobs:
- run: sudo apt-get update - run: sudo apt-get update
- run: sudo apt-get remove libunwind-14-dev - 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: 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 compile -C build
- run: meson test -C build - run: meson test -C build
build-flatpak: build-flatpak:

View file

@ -14,6 +14,7 @@ include(CTest)
option(PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING "Use WebRTC audio processing" ON) option(PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING "Use WebRTC audio processing" ON)
option(WITH_WASAPI "Use wasapi instead of directsound on windows" 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 # https://gitlab.kitware.com/cmake/cmake/-/issues/19804
if (WIN32) if (WIN32)
@ -197,6 +198,10 @@ if (WIN32)
set(CMAKE_VALA_FLAGS "${CMAKE_VALA_FLAGS} --define=_WIN32") 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_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

View file

@ -94,7 +94,7 @@ prepare()
configure_cmake() configure_cmake()
{ {
msg "Running configuration for Windows" 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!" msg "Configured!"
} }
@ -125,6 +125,7 @@ configure_meson()
meson setup ${cmd} --prefix "$DIST_DIR" \ meson setup ${cmd} --prefix "$DIST_DIR" \
-D crypto-backend=${encr} \ -D crypto-backend=${encr} \
-D plugin-ice=enabled \ -D plugin-ice=enabled \
-D select-lang=enabled \
$PROJ_DIR $BUILD_DIR $PROJ_DIR $BUILD_DIR
} }

5
configure vendored
View file

@ -2,6 +2,7 @@
OPTS=`getopt -o "h" --long \ OPTS=`getopt -o "h" --long \
help,fetch-only,no-debug,disable-fast-vapi,with-tests,release,with-libsoup3,without-webrtcdsp,\ help,fetch-only,no-debug,disable-fast-vapi,with-tests,release,with-libsoup3,without-webrtcdsp,\
enable-select-lang,\
enable-plugin:,disable-plugin:,\ enable-plugin:,disable-plugin:,\
prefix:,program-prefix:,exec-prefix:,lib-suffix:,\ prefix:,program-prefix:,exec-prefix:,lib-suffix:,\
bindir:,libdir:,includedir:,datadir:,\ bindir:,libdir:,includedir:,datadir:,\
@ -18,6 +19,7 @@ DISABLED_PLUGINS=
BUILD_TESTS=no BUILD_TESTS=no
BUILD_TYPE=Debug BUILD_TYPE=Debug
DISABLE_FAST_VAPI= DISABLE_FAST_VAPI=
ENABLE_SELECT_LANG=no
LIB_SUFFIX= LIB_SUFFIX=
NO_DEBUG= NO_DEBUG=
USE_SOUP3= USE_SOUP3=
@ -52,6 +54,7 @@ Configuration:
builds (during development). builds (during development).
--fetch-only Only fetch the files required to run ./configure --fetch-only Only fetch the files required to run ./configure
without network access later and exit. without network access later and exit.
--enable-select-lang enable language switching for the settings menu
--no-debug Build without debug symbols --no-debug Build without debug symbols
--release Configure to build an optimized release version --release Configure to build an optimized release version
--with-libsoup3 Build with libsoup-3.0 --with-libsoup3 Build with libsoup-3.0
@ -113,6 +116,7 @@ while true; do
--with-libsoup3 ) USE_SOUP3=yes; shift ;; --with-libsoup3 ) USE_SOUP3=yes; shift ;;
--without-webrtcdsp ) PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING=no; shift ;; --without-webrtcdsp ) PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING=no; shift ;;
--disable-fast-vapi ) DISABLE_FAST_VAPI=yes; shift ;; --disable-fast-vapi ) DISABLE_FAST_VAPI=yes; shift ;;
--enable-select-lang) ENABLE_SELECT_LANG=yes; shift ;;
--no-debug ) NO_DEBUG=yes; shift ;; --no-debug ) NO_DEBUG=yes; shift ;;
--release ) BUILD_TYPE=RelWithDebInfo; shift ;; --release ) BUILD_TYPE=RelWithDebInfo; shift ;;
--with-tests ) BUILD_TESTS=yes; shift ;; --with-tests ) BUILD_TESTS=yes; shift ;;
@ -223,6 +227,7 @@ cmake -G "$cmake_type" \
-DINCLUDE_INSTALL_DIR="$INCLUDEDIR" \ -DINCLUDE_INSTALL_DIR="$INCLUDEDIR" \
-DLIB_INSTALL_DIR="$LIBDIR" \ -DLIB_INSTALL_DIR="$LIBDIR" \
-DPLUGIN_RTP_WEBRTC_AUDIO_PROCESSING="$PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING" \ -DPLUGIN_RTP_WEBRTC_AUDIO_PROCESSING="$PLUGIN_RTP_WEBRTC_AUDIO_PROCESSING" \
-DENABLE_SELECT_LANG="$ENABLE_SELECT_LANG" \
-Wno-dev \ -Wno-dev \
.. || exit 9 .. || exit 9

View file

@ -34,6 +34,10 @@ public interface Application : GLib.Application {
this.settings = new Dino.Entities.Settings.from_db(db); this.settings = new Dino.Entities.Settings.from_db(db);
this.stream_interactor = new StreamInteractor(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); MessageProcessor.start(stream_interactor, db);
MessageStorage.start(stream_interactor, db); MessageStorage.start(stream_interactor, db);
PresenceManager.start(stream_interactor); PresenceManager.start(stream_interactor);

View file

@ -15,6 +15,7 @@ public class Settings : Object {
default_encryption = col_to_encryption_or_default("default_encryption", Encryption.UNKNOWN); default_encryption = col_to_encryption_or_default("default_encryption", Encryption.UNKNOWN);
send_button = col_to_bool_or_default("send_button", false); send_button = col_to_bool_or_default("send_button", false);
enter_newline = col_to_bool_or_default("enter_newline", 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) { 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; 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_; private bool send_typing_;
public bool send_typing { public bool send_typing {
get { return send_typing_; } get { return send_typing_; }
@ -128,6 +135,19 @@ public class Settings : Object {
enter_newline_ = value; 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;
}
}
} }
} }

View file

@ -140,6 +140,25 @@
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="AdwPreferencesGroup" id="select_lang_group">
<property name="visible">False</property>
<child>
<object class="AdwComboRow" id="select_lang_comborow">
<property name="title" translatable="yes">Select language</property>
<property name="subtitle" translatable="yes">Application restart required</property>
<property name="model">
<object class="GtkStringList" id="select_lang_list">
<items>
<item>English</item>
<item>Русский</item>
</items>
</object>
</property>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
</template> </template>

View file

@ -1024,6 +1024,14 @@ msgstr ""
msgid "Check spelling" msgid "Check spelling"
msgstr "" 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 #: main/data/im.dino.Dino.appdata.xml.in:7
msgid "Modern XMPP Chat Client" msgid "Modern XMPP Chat Client"
msgstr "" msgstr ""

View file

@ -1040,6 +1040,14 @@ msgstr "Превращать смайлы в эмодзи"
msgid "Check spelling" msgid "Check spelling"
msgstr "Проверка орфографии" 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 #: main/data/im.dino.Dino.appdata.xml.in:7
msgid "Modern XMPP Chat Client" msgid "Modern XMPP Chat Client"
msgstr "Современный XMPP клиент" msgstr "Современный XMPP клиент"

View file

@ -15,6 +15,10 @@ class SettingsDialog : Adw.PreferencesWindow {
[GtkChild] private unowned CheckButton encryption_radio_openpgp; [GtkChild] private unowned CheckButton encryption_radio_openpgp;
[GtkChild] private unowned Switch send_button_switch; [GtkChild] private unowned Switch send_button_switch;
[GtkChild] private unowned Switch enter_newline_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; Dino.Entities.Settings settings = Dino.Application.get_default().settings;
@ -65,6 +69,21 @@ class SettingsDialog : Adw.PreferencesWindow {
enter_newline_switch.active = visible; enter_newline_switch.active = visible;
} }
}); });
#if ENABLE_SELECT_LANG
var lang_short_list = new Gee.ArrayList<string>();
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
} }
} }

View file

@ -24,6 +24,10 @@ else
endforeach endforeach
endif endif
if get_option('select-lang').allowed()
add_project_arguments('-D', 'ENABLE_SELECT_LANG', language: 'vala')
endif
if get_option('crypto-backend') == 'auto' if get_option('crypto-backend') == 'auto'
# Prefer libgcrypt/gnutls over openssl because glib-networking is usually # Prefer libgcrypt/gnutls over openssl because glib-networking is usually
# built with gnutls anyway. # built with gnutls anyway.

View file

@ -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('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('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')