From 3badcba7b1abd2310eda7c7c04ee313c616641ea Mon Sep 17 00:00:00 2001
From: Kovid Goyal
Date: Mon, 13 Nov 2023 08:11:45 +0530
Subject: [PATCH] Fix xgettext barfing on non-ascii in text
---
src/calibre/gui2/tweak_book/editor/themes.py | 43 ++++++++++----------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/src/calibre/gui2/tweak_book/editor/themes.py b/src/calibre/gui2/tweak_book/editor/themes.py
index 3035e04e95..7f634a3eb0 100644
--- a/src/calibre/gui2/tweak_book/editor/themes.py
+++ b/src/calibre/gui2/tweak_book/editor/themes.py
@@ -493,45 +493,45 @@ the color of the blinking cursor.
As you make changes to your theme on the left, the changes will be reflected live in this panel.
-{}
+{Normal}
The most important rule. Sets the foreground and background colors for the \
editor as well as the style of "normal" text, that is, text that does not match any special syntax.
-{}
+{Visual}
Defines the colors for text selected by the mouse.
-{}
+{CursorLine}
Defines the color for the line containing the cursor.
-{}
+{LineNr}
Defines the colors for the line numbers on the left.
-{}
+{MatchParen}
Defines the colors for matching tags in HTML and matching
braces in CSS.
-{}
+{Function}
Used for highlighting tags in HTML
-{}
+{Type}
Used for highlighting attributes in HTML
-{}
+{Statement}
Tag names in HTML
-{}
+{Constant}
Namespace prefixes in XML and constants in CSS
-{}
- Non–breaking\xa0spaces/hyphens in HTML
+{SpecialCharacter}
+ Non{endash}breaking{nbsp}spaces/hyphens in HTML
-{}
+{Error}
Syntax errors such as
-{}
+{SpellError}
Misspelled words such as thisword
-{}
+{Comment}
Comments like
@@ -588,13 +588,14 @@ class ThemeEditor(Dialog):
from calibre.gui2.tweak_book.editor.text import TextEdit
self.preview = p = TextEdit(self, expected_geometry=(73, 50))
- p.load_text(HELP_TEXT.format(
- *('%s' % x for x in (
- 'Normal', 'Visual', 'CursorLine', 'LineNr', 'MatchParen',
- 'Function', 'Type', 'Statement', 'Constant', 'SpecialCharacter',
- 'Error', 'SpellError', 'Comment'
- ))
- ))
+ t = {x: f'{x}' for x in (
+ 'Normal', 'Visual', 'CursorLine', 'LineNr', 'MatchParen',
+ 'Function', 'Type', 'Statement', 'Constant', 'SpecialCharacter',
+ 'Error', 'SpellError', 'Comment')
+ }
+ t['nbsp'] = '\xa0'
+ t['endash'] = '–'
+ p.load_text(HELP_TEXT.format(**t))
p.setMaximumWidth(p.size_hint.width() + 5)
s.setMinimumWidth(600)
self.splitter = sp = QSplitter(self)