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
-
d72d04fc
by wurstsalat at 2022-10-04T11:39:21+02:00
-
758948cb
by wurstsalat at 2022-10-05T14:41:53+02:00
-
2a0cd556
by wurstsalat at 2022-10-05T13:55:42+00:00
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:
| ... | ... | @@ -107,21 +107,19 @@ def get_short_lang_code(lang: Optional[str] = None) -> str: |
| 107 | 107 | return lang[:2]
|
| 108 | 108 | |
| 109 | 109 | |
| 110 | -def paragraph_direction_mark(text: str) -> str:
|
|
| 110 | +def is_rtl_text(text: str) -> bool:
|
|
| 111 | 111 | '''
|
| 112 | 112 | Determine paragraph writing direction according to
|
| 113 | 113 | http://www.unicode.org/reports/tr9/#The_Paragraph_Level
|
| 114 | - |
|
| 115 | - Returns either Unicode LTR mark or RTL mark.
|
|
| 116 | 114 | '''
|
| 117 | 115 | for char in text:
|
| 118 | 116 | bidi = unicodedata.bidirectional(char)
|
| 119 | 117 | if bidi == 'L':
|
| 120 | - return '\u200E'
|
|
| 118 | + return False
|
|
| 121 | 119 | if bidi in ('AL', 'R'):
|
| 122 | - return '\u200F'
|
|
| 120 | + return True
|
|
| 123 | 121 | |
| 124 | - return '\u200E'
|
|
| 122 | + return False
|
|
| 125 | 123 | |
| 126 | 124 | |
| 127 | 125 | def Q_(text: str) -> str:
|
| ... | ... | @@ -61,7 +61,7 @@ |
| 61 | 61 | </child>
|
| 62 | 62 | <child>
|
| 63 | 63 | <object class="GtkButton" id="delete_button">
|
| 64 | - <property name="label">_Delete</property>
|
|
| 64 | + <property name="label" translatable="yes">_Delete</property>
|
|
| 65 | 65 | <property name="visible">True</property>
|
| 66 | 66 | <property name="sensitive">False</property>
|
| 67 | 67 | <property name="can-focus">True</property>
|
| ... | ... | @@ -158,6 +158,12 @@ .preview-button { |
| 158 | 158 | |
| 159 | 159 | .link-button { min-height: 0px; }
|
| 160 | 160 | |
| 161 | +.avatar-selector {
|
|
| 162 | + border: 2px dotted @theme_selected_bg_color;
|
|
| 163 | + border-radius: 12px;
|
|
| 164 | + padding: 18px;
|
|
| 165 | +}
|
|
| 166 | + |
|
| 161 | 167 | /* Main Window */
|
| 162 | 168 | .mainwindow-grid {
|
| 163 | 169 | background: @theme_base_color;
|
| ... | ... | @@ -69,7 +69,7 @@ class AvatarSelector(Gtk.Box): |
| 69 | 69 | def __init__(self) -> None:
|
| 70 | 70 | Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL,
|
| 71 | 71 | spacing=12)
|
| 72 | - self.get_style_context().add_class('padding-18')
|
|
| 72 | + self.get_style_context().add_class('avatar-selector')
|
|
| 73 | 73 | |
| 74 | 74 | uri_entry = Gtk.TargetEntry.new(
|
| 75 | 75 | 'text/uri-list', Gtk.TargetFlags.OTHER_APP, 80)
|
| ... | ... | @@ -44,6 +44,7 @@ |
| 44 | 44 | from gajim.common.helpers import message_needs_highlight
|
| 45 | 45 | from gajim.common.helpers import to_user_string
|
| 46 | 46 | from gajim.common.i18n import _
|
| 47 | +from gajim.common.i18n import is_rtl_text
|
|
| 47 | 48 | from gajim.common.i18n import Q_
|
| 48 | 49 | from gajim.common.modules.contacts import GroupchatContact
|
| 49 | 50 | from gajim.common.types import ChatContactT
|
| ... | ... | @@ -194,6 +195,10 @@ def __init__(self, |
| 194 | 195 | self._bottom_box = Gtk.Box(spacing=6)
|
| 195 | 196 | self._bottom_box.add(self._message_widget)
|
| 196 | 197 | |
| 198 | + if is_rtl_text(text):
|
|
| 199 | + self._bottom_box.set_halign(Gtk.Align.END)
|
|
| 200 | + self._message_widget.set_direction(Gtk.TextDirection.RTL)
|
|
| 201 | + |
|
| 197 | 202 | more_menu_button = MoreMenuButton(self, self._contact, name)
|
| 198 | 203 | more_menu_button.set_hexpand(True)
|
| 199 | 204 | more_menu_button.set_halign(Gtk.Align.END)
|
| ... | ... | @@ -443,6 +448,13 @@ def set_retracted(self, text: str) -> None: |
| 443 | 448 | self._message_widget.destroy()
|
| 444 | 449 | self._message_widget = MessageWidget(self._account)
|
| 445 | 450 | self._bottom_box.pack_start(self._message_widget, True, True, 0)
|
| 451 | + if is_rtl_text(text):
|
|
| 452 | + self._bottom_box.set_halign(Gtk.Align.END)
|
|
| 453 | + self._message_widget.set_direction(Gtk.TextDirection.RTL)
|
|
| 454 | + else:
|
|
| 455 | + self._bottom_box.set_halign(Gtk.Align.FILL)
|
|
| 456 | + self._message_widget.set_direction(Gtk.TextDirection.LTR)
|
|
| 457 | + |
|
| 446 | 458 | self._message_widget.add_with_styling(text)
|
| 447 | 459 | self.get_style_context().add_class('retracted-message')
|
| 448 | 460 | |
| ... | ... | @@ -450,6 +462,13 @@ def set_correction(self, text: str, nickname: Optional[str]) -> None: |
| 450 | 462 | if not isinstance(self._message_widget, PreviewWidget):
|
| 451 | 463 | self._message_widget.add_with_styling(text, nickname)
|
| 452 | 464 | |
| 465 | + if is_rtl_text(text):
|
|
| 466 | + self._bottom_box.set_halign(Gtk.Align.END)
|
|
| 467 | + self._message_widget.set_direction(Gtk.TextDirection.RTL)
|
|
| 468 | + else:
|
|
| 469 | + self._bottom_box.set_halign(Gtk.Align.FILL)
|
|
| 470 | + self._message_widget.set_direction(Gtk.TextDirection.LTR)
|
|
| 471 | + |
|
| 453 | 472 | self._has_receipt = False
|
| 454 | 473 | self._message_icons.set_receipt_icon_visible(False)
|
| 455 | 474 | self._message_icons.set_correction_icon_visible(True)
|
| ... | ... | @@ -137,7 +137,8 @@ def update(self, preview: Preview, data: Optional[GdkPixbufType]) -> None: |
| 137 | 137 | |
| 138 | 138 | location = split_geo_uri(preview.uri)
|
| 139 | 139 | self._ui.file_size.set_text(_('Lat: %s Lon: %s') % (
|
| 140 | - location.lat, location.lon))
|
|
| 140 | + round(float(location.lat), 5),
|
|
| 141 | + round(float(location.lon), 5)))
|
|
| 141 | 142 | self._ui.image_button.set_tooltip_text(
|
| 142 | 143 | _('Location at Lat: %s Lon: %s') % (
|
| 143 | 144 | location.lat, location.lon))
|