实现弹窗翻译功能
This commit is contained in:
parent
bc6d60fa18
commit
ecc0c3dd16
@ -23,14 +23,14 @@ class Prompt:
|
||||
def decode(self, data):
|
||||
logging.info(f'{data}')
|
||||
if data.startswith('prompt_begin'):
|
||||
self.header = data.replace('prompt_begin', '')
|
||||
self.header = _(data.replace('prompt_begin', '').lstrip())
|
||||
if self.header:
|
||||
self.window_title = self.header
|
||||
self.text = ""
|
||||
self.buttons = []
|
||||
return
|
||||
elif data.startswith('prompt_text'):
|
||||
self.text = data.replace('prompt_text ', '')
|
||||
self.text = _(data.replace('prompt_text ', '').lstrip())
|
||||
return
|
||||
elif data.startswith('prompt_button ') or data.startswith('prompt_footer_button'):
|
||||
data = data.replace('prompt_button ', '')
|
||||
@ -58,7 +58,7 @@ class Prompt:
|
||||
def set_button(self, name, gcode, style='default'):
|
||||
logging.info(f'{name} {self.id} {gcode} {style}')
|
||||
self.buttons.append(
|
||||
{"name": name, "response": self.id, 'gcode': gcode, 'style': f'dialog-{style}'}
|
||||
{"name": _(name), "response": self.id, 'gcode': gcode, 'style': f'dialog-{style}'}
|
||||
)
|
||||
self.id += 1
|
||||
|
||||
|
@ -876,7 +876,7 @@ class KlipperScreen(Gtk.Window):
|
||||
elif action == "notify_update_response":
|
||||
if 'message' in data and 'Error' in data['message']:
|
||||
logging.error(f"{action}:{data['message']}")
|
||||
self.show_popup_message(data['message'], 3, from_ws=True)
|
||||
self.show_popup_message(_(data['message'].lstrip()), 3, from_ws=True)
|
||||
if "KlipperScreen" in data['message']:
|
||||
self.restart_ks()
|
||||
elif action == "notify_power_changed":
|
||||
@ -895,9 +895,9 @@ class KlipperScreen(Gtk.Window):
|
||||
return
|
||||
self.prompt.decode(action)
|
||||
elif data.startswith("echo: "):
|
||||
self.show_popup_message(data[6:], 1, from_ws=True)
|
||||
self.show_popup_message(_(data[6:].lstrip()), 1, from_ws=True)
|
||||
elif data.startswith("!! "):
|
||||
self.show_popup_message(data[3:], 3, from_ws=True)
|
||||
self.show_popup_message(_(data[3:].lstrip()), 3, from_ws=True)
|
||||
elif "unknown" in data.lower() and \
|
||||
not ("TESTZ" in data or "MEASURE_AXES_NOISE" in data or "ACCELEROMETER_QUERY" in data):
|
||||
self.show_popup_message(data, from_ws=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user