Plugins: Set UI texts in code instead of .ui files to fix translations

Co-authored-by: srgcdev <srg.dev@posteo.net>
This commit is contained in:
fiaxh 2019-10-09 23:32:03 +02:00
parent 7adb0e82fb
commit 8e6db8859c
5 changed files with 35 additions and 21 deletions

View file

@ -40,7 +40,7 @@ public class SymmetricCipher {
case "POLY1305": return GCrypt.Cipher.Mode.POLY1305; case "POLY1305": return GCrypt.Cipher.Mode.POLY1305;
case "OCB": return GCrypt.Cipher.Mode.OCB; case "OCB": return GCrypt.Cipher.Mode.OCB;
case "CFB8": return GCrypt.Cipher.Mode.CFB8; case "CFB8": return GCrypt.Cipher.Mode.CFB8;
case "XTS": return GCrypt.Cipher.Mode.XTS; // case "XTS": return GCrypt.Cipher.Mode.XTS; // Not supported in gcrypt < 1.8
} }
return GCrypt.Cipher.Mode.NONE; return GCrypt.Cipher.Mode.NONE;
} }

View file

@ -2,7 +2,6 @@
<interface> <interface>
<template class="DinoPluginsOmemoContactDetailsDialog"> <template class="DinoPluginsOmemoContactDetailsDialog">
<property name="modal">True</property> <property name="modal">True</property>
<property name="title" translatable="yes">OMEMO Key Management</property>
<property name="resizable">False</property> <property name="resizable">False</property>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox"> <object class="GtkBox">
@ -35,10 +34,9 @@
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="automatically_accept_new_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="label" translatable="yes">Automatically accept new keys</property>
<attributes> <attributes>
<attribute name="scale" value="1.1"/> <attribute name="scale" value="1.1"/>
</attributes> </attributes>
@ -51,7 +49,6 @@
<property name="expand">True</property> <property name="expand">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="label" translatable="yes">When this contact adds new encryption keys to their account, automatically accept them.</property>
<attributes> <attributes>
<attribute name="scale" value="0.8"/> <attribute name="scale" value="0.8"/>
</attributes> </attributes>
@ -83,10 +80,9 @@
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">2</property> <property name="spacing">2</property>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="own_key_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="label" translatable="yes">Own key</property>
<attributes> <attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/> <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes> </attributes>
@ -174,10 +170,9 @@
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">2</property> <property name="spacing">2</property>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="new_keys_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="label" translatable="yes">New keys</property>
<attributes> <attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/> <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes> </attributes>
@ -210,10 +205,9 @@
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">2</property> <property name="spacing">2</property>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="associated_keys_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="halign">start</property> <property name="halign">start</property>
<property name="label" translatable="yes">Associated keys</property>
<attributes> <attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/> <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes> </attributes>

View file

@ -4,13 +4,11 @@
<property name="modal">True</property> <property name="modal">True</property>
<property name="resizable">False</property> <property name="resizable">False</property>
<child type="titlebar"> <child type="titlebar">
<object class="GtkHeaderBar" id="header_bar"> <object class="GtkHeaderBar" id="headerbar">
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">Manage Key</property>
<property name="show_close_button">False</property> <property name="show_close_button">False</property>
<child> <child>
<object class="GtkButton" id="cancel_button"> <object class="GtkButton" id="cancel_button">
<property name="label" translatable="yes">Cancel</property>
<property name="sensitive">True</property> <property name="sensitive">True</property>
<property name="visible">True</property> <property name="visible">True</property>
</object> </object>
@ -22,7 +20,6 @@
<object class="GtkButton" id="ok_button"> <object class="GtkButton" id="ok_button">
<property name="has_default">True</property> <property name="has_default">True</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="label" translatable="yes">Confirm</property>
<property name="sensitive">False</property> <property name="sensitive">False</property>
<property name="visible">True</property> <property name="visible">True</property>
<style> <style>
@ -81,11 +78,10 @@
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="valign">center</property> <property name="valign">center</property>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="compare_fingerprint_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Compare the fingerprint, character by character, with the one shown on your contacts device.</property>
<property name="wrap">True</property> <property name="wrap">True</property>
<property name="xalign">0</property> <property name="xalign">0.5</property>
<property name="max-width-chars">45</property> <property name="max-width-chars">45</property>
</object> </object>
</child> </child>
@ -110,14 +106,12 @@
<object class="GtkButton" id="verify_no_button"> <object class="GtkButton" id="verify_no_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="label" translatable="yes">Not matching</property>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkButton" id="verify_yes_button"> <object class="GtkButton" id="verify_yes_button">
<property name="visible">True</property> <property name="visible">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="label" translatable="yes">Matching</property>
</object> </object>
</child> </child>
</object> </object>

View file

@ -17,7 +17,11 @@ public class ContactDetailsDialog : Gtk.Dialog {
private bool own = false; private bool own = false;
private int own_id = 0; private int own_id = 0;
[GtkChild] private Label automatically_accept_new_label;
[GtkChild] private Label automatically_accept_new_descr; [GtkChild] private Label automatically_accept_new_descr;
[GtkChild] private Label own_key_label;
[GtkChild] private Label new_keys_label;
[GtkChild] private Label associated_keys_label;
[GtkChild] private Box own_fingerprint_container; [GtkChild] private Box own_fingerprint_container;
[GtkChild] private Label own_fingerprint_label; [GtkChild] private Label own_fingerprint_label;
[GtkChild] private Box new_keys_container; [GtkChild] private Box new_keys_container;
@ -30,6 +34,16 @@ public class ContactDetailsDialog : Gtk.Dialog {
[GtkChild] private Image qrcode_image; [GtkChild] private Image qrcode_image;
[GtkChild] private Popover qrcode_popover; [GtkChild] private Popover qrcode_popover;
construct {
// If we set the strings in the .ui file, they don't get translated
title = _("OMEMO Key Management");
automatically_accept_new_label.label = _("Automatically accept new keys");
automatically_accept_new_descr.label = _("When this contact adds new encryption keys to their account, automatically accept them.");
own_key_label.label = _("Own key");
new_keys_label.label = _("New keys");
associated_keys_label.label = _("Associated keys");
}
public ContactDetailsDialog(Plugin plugin, Account account, Jid jid) { public ContactDetailsDialog(Plugin plugin, Account account, Jid jid) {
Object(use_header_bar : Environment.get_variable("GTK_CSD") != "0" ? 1 : 0); Object(use_header_bar : Environment.get_variable("GTK_CSD") != "0" ? 1 : 0);
this.plugin = plugin; this.plugin = plugin;

View file

@ -6,6 +6,7 @@ namespace Dino.Plugins.Omemo {
[GtkTemplate (ui = "/im/dino/Dino/omemo/manage_key_dialog.ui")] [GtkTemplate (ui = "/im/dino/Dino/omemo/manage_key_dialog.ui")]
public class ManageKeyDialog : Gtk.Dialog { public class ManageKeyDialog : Gtk.Dialog {
[GtkChild] private HeaderBar headerbar;
[GtkChild] private Stack manage_stack; [GtkChild] private Stack manage_stack;
[GtkChild] private Button cancel_button; [GtkChild] private Button cancel_button;
@ -19,6 +20,7 @@ public class ManageKeyDialog : Gtk.Dialog {
[GtkChild] private Label confirm_desc_label; [GtkChild] private Label confirm_desc_label;
[GtkChild] private Label verify_label; [GtkChild] private Label verify_label;
[GtkChild] private Label compare_fingerprint_label;
[GtkChild] private Button verify_yes_button; [GtkChild] private Button verify_yes_button;
[GtkChild] private Button verify_no_button; [GtkChild] private Button verify_no_button;
@ -28,6 +30,16 @@ public class ManageKeyDialog : Gtk.Dialog {
private bool return_to_main; private bool return_to_main;
private int current_response; private int current_response;
construct {
// If we set the strings in the .ui file, they don't get translated
headerbar.title = _("Manage Key");
compare_fingerprint_label.label = _("Compare the fingerprint, character by character, with the one shown on your contacts device.");
verify_no_button.label = _("Not matching");
verify_yes_button.label = _("Matching");
cancel_button.label = _("Cancel");
ok_button.label = _("Confirm");
}
public ManageKeyDialog(Row device, Database db) { public ManageKeyDialog(Row device, Database db) {
Object(use_header_bar : Environment.get_variable("GTK_CSD") != "0" ? 1 : 0); Object(use_header_bar : Environment.get_variable("GTK_CSD") != "0" ? 1 : 0);