Philipp Hörist pushed to branch i18n-bidi at gajim / gajim
Commits: 1adc22ec by Daniel Brötzmann at 2022-10-04T08:53:14+00:00 cfix: PEPConfig: Make Delete button translatable - - - - - d72d04fc by wurstsalat at 2022-10-04T11:39:21+02:00 imprv: AvatarSelector: Add border to mark drag and drop zone
- - - - - 758948cb by wurstsalat at 2022-10-05T14:41:53+02:00 cfix: Preview: Limit displayed geo:-URI precision
- - - - - 2a0cd556 by wurstsalat at 2022-10-05T13:55:42+00:00 imprv: MessageRow: Set text direction for RTL text
Fixes #11148
- - - - -
6 changed files:
- gajim/common/i18n.py - gajim/data/gui/pep_config.ui - gajim/data/style/gajim.css - gajim/gtk/avatar_selector.py - gajim/gtk/conversation/rows/message.py - gajim/gtk/preview.py
Changes:
===================================== gajim/common/i18n.py ===================================== @@ -107,21 +107,19 @@ def get_short_lang_code(lang: Optional[str] = None) -> str: return lang[:2]
-def paragraph_direction_mark(text: str) -> str: +def is_rtl_text(text: str) -> bool: ''' Determine paragraph writing direction according to http://www.unicode.org/reports/tr9/#The_Paragraph_Level - - Returns either Unicode LTR mark or RTL mark. ''' for char in text: bidi = unicodedata.bidirectional(char) if bidi == 'L': - return '\u200E' + return False if bidi in ('AL', 'R'): - return '\u200F' + return True
- return '\u200E' + return False
def Q_(text: str) -> str:
===================================== gajim/data/gui/pep_config.ui ===================================== @@ -61,7 +61,7 @@ </child> <child> <object class="GtkButton" id="delete_button"> - <property name="label">_Delete</property> + <property name="label" translatable="yes">_Delete</property> <property name="visible">True</property> <property name="sensitive">False</property> <property name="can-focus">True</property>
===================================== gajim/data/style/gajim.css ===================================== @@ -158,6 +158,12 @@ .preview-button {
.link-button { min-height: 0px; }
+.avatar-selector { + border: 2px dotted @theme_selected_bg_color; + border-radius: 12px; + padding: 18px; +} + /* Main Window */ .mainwindow-grid { background: @theme_base_color;
===================================== gajim/gtk/avatar_selector.py ===================================== @@ -69,7 +69,7 @@ class AvatarSelector(Gtk.Box): def __init__(self) -> None: Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=12) - self.get_style_context().add_class('padding-18') + self.get_style_context().add_class('avatar-selector')
uri_entry = Gtk.TargetEntry.new( 'text/uri-list', Gtk.TargetFlags.OTHER_APP, 80)
===================================== gajim/gtk/conversation/rows/message.py ===================================== @@ -44,6 +44,7 @@ from gajim.common.helpers import message_needs_highlight from gajim.common.helpers import to_user_string from gajim.common.i18n import _ +from gajim.common.i18n import is_rtl_text from gajim.common.i18n import Q_ from gajim.common.modules.contacts import GroupchatContact from gajim.common.types import ChatContactT @@ -194,6 +195,10 @@ def __init__(self, self._bottom_box = Gtk.Box(spacing=6) self._bottom_box.add(self._message_widget)
+ if is_rtl_text(text): + self._bottom_box.set_halign(Gtk.Align.END) + self._message_widget.set_direction(Gtk.TextDirection.RTL) + more_menu_button = MoreMenuButton(self, self._contact, name) more_menu_button.set_hexpand(True) more_menu_button.set_halign(Gtk.Align.END) @@ -443,6 +448,13 @@ def set_retracted(self, text: str) -> None: self._message_widget.destroy() self._message_widget = MessageWidget(self._account) self._bottom_box.pack_start(self._message_widget, True, True, 0) + if is_rtl_text(text): + self._bottom_box.set_halign(Gtk.Align.END) + self._message_widget.set_direction(Gtk.TextDirection.RTL) + else: + self._bottom_box.set_halign(Gtk.Align.FILL) + self._message_widget.set_direction(Gtk.TextDirection.LTR) + self._message_widget.add_with_styling(text) self.get_style_context().add_class('retracted-message')
@@ -450,6 +462,13 @@ def set_correction(self, text: str, nickname: Optional[str]) -> None: if not isinstance(self._message_widget, PreviewWidget): self._message_widget.add_with_styling(text, nickname)
+ if is_rtl_text(text): + self._bottom_box.set_halign(Gtk.Align.END) + self._message_widget.set_direction(Gtk.TextDirection.RTL) + else: + self._bottom_box.set_halign(Gtk.Align.FILL) + self._message_widget.set_direction(Gtk.TextDirection.LTR) + self._has_receipt = False self._message_icons.set_receipt_icon_visible(False) self._message_icons.set_correction_icon_visible(True)
===================================== gajim/gtk/preview.py ===================================== @@ -137,7 +137,8 @@ def update(self, preview: Preview, data: Optional[GdkPixbufType]) -> None:
location = split_geo_uri(preview.uri) self._ui.file_size.set_text(_('Lat: %s Lon: %s') % ( - location.lat, location.lon)) + round(float(location.lat), 5), + round(float(location.lon), 5))) self._ui.image_button.set_tooltip_text( _('Location at Lat: %s Lon: %s') % ( location.lat, location.lon))
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/eaaaf8a708d88f6e7a97cadba09f75d2...