Update to allow translations from config file. Updates to use translations from config file.

This commit is contained in:
Jordan Ruthe
2021-01-03 12:43:53 -05:00
parent c08a293f83
commit 3c2bdee22a
7 changed files with 307 additions and 90 deletions

19
docs/Translations.md Normal file
View File

@@ -0,0 +1,19 @@
## Create Translations
You can use a editor such as [poedit](https://poedit.net/) to assist in translations. This guide will assume that you
will be using poedit.
This guide will refer to `language designation`. This can be found from running `echo $LANG` on your pi, as long as you
have set your pi up for your preferred language.
#### New Language
* Select `Create a new translation` or `File -> New from POT/PO` and select `ks_includes/locals/KlipperScreen.pot`.
* Enter your language designation.
* Create the translations
* Save the file as `ks_includes/locales/{LANGUAGE DESIGNATION}/KlipperScreen.po`.
* Select `File -> Compile to MO`. Save this file as `ks_includes/locales/{LANGUAGE DESIGNATION}/KlipperScreen.mo`
Once you have followed those steps, as long as your pi is set up for your preferred language, KlipperScreen will
automatically use the translations provided in the file. KlipperScreen currently does not detect RTL languages, but
support for RTL is planned in the near future.

View File

@@ -11,165 +11,165 @@ bed = 90
extruder = 220 extruder = 220
[menu __main] [menu __main]
name: Main Menu name: {{ gettext('Main Menu') }}
[menu __main homing] [menu __main homing]
name: Homing name: {{ gettext('Homing') }}
icon: home icon: home
[menu __main preheat] [menu __main preheat]
name: Preheat name: {{ gettext('Preheat') }}
icon: heat-up icon: heat-up
panel: preheat panel: preheat
[menu __main actions] [menu __main actions]
name: Actions name: {{ gettext('Actions') }}
icon: actions icon: actions
[menu __main config] [menu __main config]
name: Configuration name: {{ gettext('Configuration') }}
icon: control icon: control
[menu __main print] [menu __main print]
name: Print name: {{ gettext('Print') }}
icon: print icon: print
panel: print panel: print
[menu __main homing homeall] [menu __main homing homeall]
name: Home All name: {{ gettext('Home All') }}
icon: home icon: home
method: printer.gcode.script method: printer.gcode.script
params: {"script":"G28"} params: {"script":"G28"}
[menu __main homing homex] [menu __main homing homex]
name: Home X name: {{ gettext('Home X') }}
icon: home-x icon: home-x
method: printer.gcode.script method: printer.gcode.script
params: {"script":"G28 X"} params: {"script":"G28 X"}
[menu __main homing homey] [menu __main homing homey]
name: Home Y name: {{ gettext('Home Y') }}
icon: home-y icon: home-y
method: printer.gcode.script method: printer.gcode.script
params: {"script":"G28 Y"} params: {"script":"G28 Y"}
[menu __main homing homez] [menu __main homing homez]
name: Home Z name: {{ gettext('Home Z') }}
icon: home-z icon: home-z
method: printer.gcode.script method: printer.gcode.script
params: {"script":"G28 Z"} params: {"script":"G28 Z"}
[menu __main homing homexy] [menu __main homing homexy]
name: Home XY name: {{ gettext('Home XY') }}
icon: home icon: home
method: printer.gcode.script method: printer.gcode.script
params: {"script":"G28 X Y"} params: {"script":"G28 X Y"}
[menu __main actions move] [menu __main actions move]
name: Move name: {{ gettext('Move') }}
icon: move icon: move
panel: move panel: move
[menu __main actions extrude] [menu __main actions extrude]
name: Extrude name: {{ gettext('Extrude') }}
icon: filament icon: filament
panel: extrude panel: extrude
[menu __main actions fan] [menu __main actions fan]
name: Fan name: {{ gettext('Fan') }}
icon: fan icon: fan
panel: fan panel: fan
[menu __main actions temperature] [menu __main actions temperature]
name: Temperature name: {{ gettext('Temperature') }}
icon: heat-up icon: heat-up
panel: temperature panel: temperature
[menu __main actions macros] [menu __main actions macros]
name: Macros name: {{ gettext('Macros') }}
icon: custom-script icon: custom-script
panel: gcode_macros panel: gcode_macros
enable: {{ printer.gcode_macros.count > 0 }} enable: {{ printer.gcode_macros.count > 0 }}
[menu __main actions power] [menu __main actions power]
name: Power name: {{ gettext('Power') }}
icon: shutdown icon: shutdown
panel: power panel: power
enable: {{ printer.power_devices.count > 0 }} enable: {{ printer.power_devices.count > 0 }}
[menu __main actions disablemotors] [menu __main actions disablemotors]
name: Disable Motors name: {{ gettext('Disable Motors') }}
icon: motor-off icon: motor-off
method: printer.gcode.script method: printer.gcode.script
params: {"script":"M18"} params: {"script":"M18"}
[menu __main config bedlevel] [menu __main config bedlevel]
name: Bed Level name: {{ gettext('Bed Level') }}
icon: bed-level icon: bed-level
panel: bed_level panel: bed_level
[menu __main config bedmesh] [menu __main config bedmesh]
name: Bed Mesh name: {{ gettext('Bed Mesh') }}
icon: bed-level icon: bed-level
panel: bed_mesh panel: bed_mesh
enable: {{ printer.bed_mesh is defined }} enable: {{ printer.bed_mesh is defined }}
[menu __main config zoffset] [menu __main config zoffset]
name: Z Calibrate name: {{ gettext('Z Calibrate') }}
icon: z-offset-increase icon: z-offset-increase
panel: zcalibrate panel: zcalibrate
enable: {{ ((printer.bltouch is defined) or (printer.probe is defined)) }} enable: {{ ((printer.bltouch is defined) or (printer.probe is defined)) }}
[menu __main config network] [menu __main config network]
name: Network name: {{ gettext('Network') }}
icon: network icon: network
panel: network panel: network
[menu __main config system] [menu __main config system]
name: System name: {{ gettext('System') }}
icon: info icon: info
panel: system panel: system
[menu __main config save] [menu __main config save]
name: Save Config name: {{ gettext('Save Config') }}
icon: complete icon: complete
method: printer.gcode.script method: printer.gcode.script
params: {"script":"SAVE_CONFIG"} params: {"script":"SAVE_CONFIG"}
confirm: confirm:
Save configuration. {{ gettext('Save configuration.') }}
Klipper will reboot {{ gettext('Klipper will reboot') }}
[menu __print] [menu __print]
name: Print Control name: {{ gettext('Print Control') }}
[menu __print temperature] [menu __print temperature]
name: Temperature name: {{ gettext('Temperature') }}
icon: heat-up icon: heat-up
panel: temperature panel: temperature
[menu __print tuning] [menu __print tuning]
name: Fine Tuning name: {{ gettext('Fine Tuning') }}
icon: fan icon: fan
panel: fine_tune panel: fine_tune
[menu __print fan] [menu __print fan]
name: Fan name: {{ gettext('Fan') }}
icon: fan icon: fan
panel: fan panel: fan
[menu __print extrude] [menu __print extrude]
name: Extrude name: {{ gettext('Extrude') }}
icon: filament icon: filament
panel: extrude panel: extrude
enable: {{ printer.pause_resume.is_paused == True }} enable: {{ printer.pause_resume.is_paused == True }}
[menu __print network] [menu __print network]
name: Network name: {{ gettext('Network') }}
icon: network icon: network
panel: network panel: network
[menu __print system] [menu __print system]
name: System name: {{ gettext('System') }}
icon: info icon: info
panel: system panel: system

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-11-18 12:37+0000\n" "POT-Creation-Date: 2021-01-03 17:33+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -17,23 +17,27 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: panels/print.py:229 #: panels/print.py:229 panels/print.py:197
msgid "?" msgid "?"
msgstr "" msgstr ""
#: panels/zcalibrate.py:65 #: panels/zcalibrate.py:65 panels/zcalibrate.py:70
msgid "Abort" msgid "Abort"
msgstr "" msgstr ""
#: panels/zcalibrate.py:61 #: panels/zcalibrate.py:61 panels/zcalibrate.py:67
msgid "Accept" msgid "Accept"
msgstr "" msgstr ""
#: panels/print.py:229 #: ks_includes/KlipperScreen.conf:26
msgid "Actions"
msgstr ""
#: panels/print.py:229 panels/print.py:197
msgid "Are you sure you want to print" msgid "Are you sure you want to print"
msgstr "" msgstr ""
#: panels/job_status.py:108 #: panels/job_status.py:108 panels/job_status.py:305
msgid "Are you sure you wish to cancel this print?" msgid "Are you sure you wish to cancel this print?"
msgstr "" msgstr ""
@@ -43,47 +47,79 @@ msgstr ""
msgid "Back" msgid "Back"
msgstr "" msgstr ""
#: panels/job_status.py:79 panels/print.py:225 #: ks_includes/KlipperScreen.conf:107
msgid "Bed Level"
msgstr ""
#: ks_includes/KlipperScreen.conf:112
msgid "Bed Mesh"
msgstr ""
#: panels/job_status.py:79 panels/print.py:225 screen.py:440
#: panels/job_status.py:267 panels/print.py:193
msgid "Cancel" msgid "Cancel"
msgstr "" msgstr ""
#: panels/fan.py:42 #: panels/fan.py:42 panels/fan.py:45
msgid "Cancel Change" msgid "Cancel Change"
msgstr "" msgstr ""
#: panels/job_status.py:111 #: panels/job_status.py:111 panels/job_status.py:300
msgid "Cancel Print" msgid "Cancel Print"
msgstr "" msgstr ""
#: panels/temperature.py:146 #: screen.py:274
msgid ""
"Check /tmp/KlipperScreen.log for more information.\n"
"Please submit an issue on GitHub for help."
msgstr ""
#: panels/temperature.py:146 panels/bed_mesh.py:172 panels/temperature.py:149
msgid "Close" msgid "Close"
msgstr "" msgstr ""
#: panels/job_status.py:85 #: ks_includes/KlipperScreen.conf:30
msgid "Configuration"
msgstr ""
#: screen.py:439
msgid "Continue"
msgstr ""
#: panels/job_status.py:85 panels/job_status.py:269
msgid "Control" msgid "Control"
msgstr "" msgstr ""
#: panels/preheat.py:51 #: panels/preheat.py:51 panels/preheat.py:54
msgid "Cooldown" msgid "Cooldown"
msgstr "" msgstr ""
#: panels/temperature.py:49 #: panels/temperature.py:49 panels/temperature.py:53
msgid "Decrease" msgid "Decrease"
msgstr "" msgstr ""
#: panels/bed_level.py:79 #: ks_includes/KlipperScreen.conf:101
msgid "Disable Motors"
msgstr ""
#: panels/bed_level.py:79 panels/bed_level.py:101
msgid "Disable XY" msgid "Disable XY"
msgstr "" msgstr ""
#: panels/zcalibrate.py:57 #: panels/zcalibrate.py:57 panels/zcalibrate.py:63
msgid "Distance (mm)" msgid "Distance (mm)"
msgstr "" msgstr ""
#: panels/bed_level.py:85 panels/job_status.py:82 #: panels/job_status.py:135
msgid "Elapsed:"
msgstr ""
#: panels/bed_level.py:85 panels/job_status.py:82 panels/job_status.py:271
msgid "Emergency Stop" msgid "Emergency Stop"
msgstr "" msgstr ""
#: panels/extrude.py:32 #: panels/extrude.py:32 panels/extrude.py:43 ks_includes/KlipperScreen.conf:74
#: ks_includes/KlipperScreen.conf:167
msgid "Extrude" msgid "Extrude"
msgstr "" msgstr ""
@@ -91,15 +127,16 @@ msgstr ""
msgid "Extrusion" msgid "Extrusion"
msgstr "" msgstr ""
#: panels/fine_tune.py:64 #: panels/fine_tune.py:64 panels/fine_tune.py:57
msgid "Extrusion +" msgid "Extrusion +"
msgstr "" msgstr ""
#: panels/fine_tune.py:68 #: panels/fine_tune.py:68 panels/fine_tune.py:61
msgid "Extrusion -" msgid "Extrusion -"
msgstr "" msgstr ""
#: panels/fine_tune.py:46 panels/fine_tune.py:141 #: panels/fine_tune.py:46 panels/fine_tune.py:141
#: ks_includes/KlipperScreen.conf:79 ks_includes/KlipperScreen.conf:162
msgid "Fan" msgid "Fan"
msgstr "" msgstr ""
@@ -111,111 +148,238 @@ msgstr ""
msgid "Fan -" msgid "Fan -"
msgstr "" msgstr ""
#: panels/fan.py:32 #: panels/fan.py:32 panels/fan.py:35
msgid "Fan Off" msgid "Fan Off"
msgstr "" msgstr ""
#: panels/fan.py:35 #: panels/fan.py:35 panels/fan.py:38
msgid "Fan On" msgid "Fan On"
msgstr "" msgstr ""
#: panels/extrude.py:21 panels/extrude.py:25 #: panels/extrude.py:21 panels/extrude.py:25 panels/extrude.py:23
#: panels/extrude.py:27
msgid "Fast" msgid "Fast"
msgstr "" msgstr ""
#: panels/system.py:22 panels/splash_screen.py:59 #: ks_includes/KlipperScreen.conf:157
msgid "Fine Tuning"
msgstr ""
#: panels/system.py:22 panels/splash_screen.py:59 panels/splash_screen.py:62
#: panels/system.py:24
msgid "Firmware Restart" msgid "Firmware Restart"
msgstr "" msgstr ""
#: panels/job_status.py:115 #: panels/job_status.py:115 screen.py:269 panels/job_status.py:301
msgid "Go Back" msgid "Go Back"
msgstr "" msgstr ""
#: panels/bed_level.py:76 panels/move.py:38 #: panels/bed_level.py:76 panels/move.py:38 panels/bed_level.py:98
#: panels/move.py:40 ks_includes/KlipperScreen.conf:39
msgid "Home All" msgid "Home All"
msgstr "" msgstr ""
#: panels/zcalibrate.py:25 #: ks_includes/KlipperScreen.conf:45
msgid "Home X"
msgstr ""
#: ks_includes/KlipperScreen.conf:63
msgid "Home XY"
msgstr ""
#: ks_includes/KlipperScreen.conf:51
msgid "Home Y"
msgstr ""
#: ks_includes/KlipperScreen.conf:57
msgid "Home Z"
msgstr ""
#: panels/zcalibrate.py:25 panels/zcalibrate.py:29
#: ks_includes/KlipperScreen.conf:17
msgid "Homing" msgid "Homing"
msgstr "" msgstr ""
#: panels/temperature.py:47 #: panels/temperature.py:47 panels/temperature.py:51
msgid "Increase" msgid "Increase"
msgstr "" msgstr ""
#. self._load_panels()
#: screen.py:121
msgid "Initializing"
msgstr ""
#: panels/splash_screen.py:23 #: panels/splash_screen.py:23
msgid "Initializing printer..." msgid "Initializing printer..."
msgstr "" msgstr ""
#: panels/system.py:20 #: ks_includes/KlipperScreen.conf:144
msgid "KS Settings"
msgstr ""
#: panels/system.py:20 panels/system.py:22
msgid "Klipper Restart" msgid "Klipper Restart"
msgstr "" msgstr ""
#: panels/system.py:43 panels/system.py:42 #: panels/system.py:35
msgid "Klipper Version"
msgstr ""
#: screen.py:369
msgid "Klipper has disconnected"
msgstr ""
#: screen.py:380
msgid ""
"Klipper has encountered an error with the micro-controller.\n"
"Please recompile and flash."
msgstr ""
#: screen.py:384
msgid "Klipper has encountered an error."
msgstr ""
#: screen.py:376
msgid ""
"Klipper has encountered an error.\n"
"Issue a FIRMWARE_RESTART to attempt fixing the issue."
msgstr ""
#: screen.py:402
msgid "Klipper has shutdown"
msgstr ""
#: screen.py:398
msgid "Klipper is attempting to start"
msgstr ""
#: ks_includes/KlipperScreen.conf:141
msgid "Klipper will reboot"
msgstr ""
#: panels/system.py:43 panels/system.py:42 panels/system.py:39
msgid "KlipperScreen Version" msgid "KlipperScreen Version"
msgstr "" msgstr ""
#: panels/system.py:62 #: panels/job_status.py:123
msgid "Left:"
msgstr ""
#: panels/system.py:62 panels/system.py:57
msgid "Load Average" msgid "Load Average"
msgstr "" msgstr ""
#: panels/zcalibrate.py:34 #: panels/zcalibrate.py:34 panels/zcalibrate.py:39
msgid "Lower Nozzle" msgid "Lower Nozzle"
msgstr "" msgstr ""
#: ks_includes/KlipperScreen.conf:89
msgid "Macros"
msgstr ""
#: panels/job_status.py:273 ks_includes/KlipperScreen.conf:14
msgid "Main Menu"
msgstr ""
#: panels/extrude.py:20 panels/extrude.py:21 panels/extrude.py:24 #: panels/extrude.py:20 panels/extrude.py:21 panels/extrude.py:24
#: panels/extrude.py:22 panels/extrude.py:23 panels/extrude.py:26
msgid "Medium" msgid "Medium"
msgstr "" msgstr ""
#: panels/move.py:87 #: ks_includes/KlipperScreen.conf:69
msgid "Move"
msgstr ""
#: panels/move.py:87 panels/move.py:86
msgid "Move Distance (mm)" msgid "Move Distance (mm)"
msgstr "" msgstr ""
#: panels/network.py:28 #: ks_includes/KlipperScreen.conf:124 ks_includes/KlipperScreen.conf:173
msgid "Network"
msgstr ""
#: panels/network.py:28 panels/network.py:31
msgid "Network Info" msgid "Network Info"
msgstr "" msgstr ""
#: panels/temperature.py:51 #: panels/temperature.py:51 panels/temperature.py:55
msgid "Number Pad" msgid "Number Pad"
msgstr "" msgstr ""
#: panels/job_status.py:70 #: panels/job_status.py:70 panels/job_status.py:275
msgid "Pause" msgid "Pause"
msgstr "" msgstr ""
#: panels/print.py:224 #: panels/job_status.py:454
msgid "Paused"
msgstr ""
#: ks_includes/KlipperScreen.conf:95
msgid "Power"
msgstr ""
#: panels/splash_screen.py:59
msgid "Power On Printer"
msgstr ""
#: ks_includes/KlipperScreen.conf:21
msgid "Preheat"
msgstr ""
#: panels/print.py:224 panels/print.py:192 ks_includes/KlipperScreen.conf:34
msgid "Print" msgid "Print"
msgstr "" msgstr ""
#: panels/print.py:154 #: ks_includes/KlipperScreen.conf:149
msgid "Print Control"
msgstr ""
#: panels/print.py:154 panels/print.py:122
msgid "Print Time" msgid "Print Time"
msgstr "" msgstr ""
#: panels/zcalibrate.py:32 #: panels/job_status.py:231
msgid "Printing"
msgstr ""
#: panels/zcalibrate.py:32 panels/zcalibrate.py:37
msgid "Raise Nozzle" msgid "Raise Nozzle"
msgstr "" msgstr ""
#: panels/splash_screen.py:57 #: panels/splash_screen.py:57 panels/job_status.py:277
#: panels/splash_screen.py:60
msgid "Restart" msgid "Restart"
msgstr "" msgstr ""
#: panels/job_status.py:68 #: panels/job_status.py:68 panels/job_status.py:279
msgid "Resume" msgid "Resume"
msgstr "" msgstr ""
#: panels/extrude.py:34 #: panels/extrude.py:34 panels/extrude.py:45
msgid "Retract" msgid "Retract"
msgstr "" msgstr ""
#: panels/fan.py:39 #: ks_includes/KlipperScreen.conf:134
msgid "Save Config"
msgstr ""
#: ks_includes/KlipperScreen.conf:139
msgid "Save configuration."
msgstr ""
#: panels/bed_level.py:108
msgid "Screws Adjust"
msgstr ""
#: panels/fan.py:39 panels/fan.py:42
msgid "Set Speed" msgid "Set Speed"
msgstr "" msgstr ""
#: panels/print.py:152 #: panels/print.py:152 panels/print.py:120
msgid "Size" msgid "Size"
msgstr "" msgstr ""
#: panels/extrude.py:21 panels/extrude.py:23 #: panels/extrude.py:21 panels/extrude.py:23 panels/extrude.py:25
msgid "Slow" msgid "Slow"
msgstr "" msgstr ""
@@ -223,19 +387,24 @@ msgstr ""
msgid "Speed" msgid "Speed"
msgstr "" msgstr ""
#: panels/fine_tune.py:54 #: panels/fine_tune.py:54 panels/fine_tune.py:47
msgid "Speed +" msgid "Speed +"
msgstr "" msgstr ""
#: panels/fine_tune.py:58 #: panels/fine_tune.py:58 panels/fine_tune.py:51
msgid "Speed -" msgid "Speed -"
msgstr "" msgstr ""
#: ks_includes/KlipperScreen.conf:129 ks_includes/KlipperScreen.conf:178
msgid "System"
msgstr ""
#: panels/system.py:31 panels/system.py:30 #: panels/system.py:31 panels/system.py:30
msgid "System Information" msgid "System Information"
msgstr "" msgstr ""
#: panels/extrude.py:36 #: panels/extrude.py:36 panels/extrude.py:47 ks_includes/KlipperScreen.conf:84
#: ks_includes/KlipperScreen.conf:152
msgid "Temperature" msgid "Temperature"
msgstr "" msgstr ""
@@ -247,42 +416,53 @@ msgstr ""
msgid "Time Left" msgid "Time Left"
msgstr "" msgstr ""
#: panels/extrude.py:35
msgid "Tool"
msgstr ""
#: panels/extrude.py:30 #: panels/extrude.py:30
msgid "Tool 1" msgid "Tool 1"
msgstr "" msgstr ""
#: panels/print.py:150 #: panels/print.py:150 panels/print.py:118
msgid "Uploaded" msgid "Uploaded"
msgstr "" msgstr ""
#: panels/move.py:23 #: panels/move.py:23 panels/move.py:25
msgid "X+" msgid "X+"
msgstr "" msgstr ""
#: panels/move.py:25 #: panels/move.py:25 panels/move.py:27
msgid "X-" msgid "X-"
msgstr "" msgstr ""
#: panels/move.py:28 #: panels/move.py:28 panels/move.py:30
msgid "Y+" msgid "Y+"
msgstr "" msgstr ""
#: panels/move.py:30 #: panels/move.py:30 panels/move.py:32
msgid "Y-" msgid "Y-"
msgstr "" msgstr ""
#: ks_includes/KlipperScreen.conf:118
msgid "Z Calibrate"
msgstr ""
#: panels/fine_tune.py:35 panels/fine_tune.py:131 panels/zcalibrate.py:23 #: panels/fine_tune.py:35 panels/fine_tune.py:131 panels/zcalibrate.py:23
#: panels/zcalibrate.py:28
msgid "Z Offset" msgid "Z Offset"
msgstr "" msgstr ""
#: panels/fine_tune.py:33 panels/move.py:33 #: panels/fine_tune.py:33 panels/move.py:33 panels/fine_tune.py:36
#: panels/move.py:35
msgid "Z+" msgid "Z+"
msgstr "" msgstr ""
#: panels/fine_tune.py:37 panels/move.py:35 #: panels/fine_tune.py:37 panels/move.py:35 panels/fine_tune.py:40
#: panels/move.py:37
msgid "Z-" msgid "Z-"
msgstr "" msgstr ""
#: panels/fine_tune.py:35 #: panels/fine_tune.py:35 panels/fine_tune.py:38
msgid "mm" msgid "mm"
msgstr "" msgstr ""

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import gi import gi
import logging import logging
import math import math

View File

@@ -1,9 +1,10 @@
import gettext
import gi import gi
import logging import logging
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib from gi.repository import Gtk, Gdk, GLib
from jinja2 import Template from jinja2 import Environment, Template
from ks_includes.screen_panel import ScreenPanel from ks_includes.screen_panel import ScreenPanel
@@ -57,8 +58,14 @@ class MenuPanel(ScreenPanel):
for i in range(len(self.items)): for i in range(len(self.items)):
key = list(self.items[i])[0] key = list(self.items[i])[0]
item = self.items[i][key] item = self.items[i][key]
env = Environment(extensions=["jinja2.ext.i18n"])
env.install_gettext_translations(self.lang)
j2_temp = env.from_string(item['name'])
parsed_name = j2_temp.render()
b = self._gtk.ButtonImage( b = self._gtk.ButtonImage(
item['icon'], item['name'], "color"+str((i%4)+1) item['icon'], parsed_name, "color"+str((i%4)+1)
) )
if item['panel'] != False: if item['panel'] != False:
b.connect("clicked", self.menu_item_clicked, item['panel'], item) b.connect("clicked", self.menu_item_clicked, item['panel'], item)

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import gi import gi
import logging import logging

View File

@@ -18,6 +18,7 @@ import subprocess
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib, Pango from gi.repository import Gtk, Gdk, GLib, Pango
from jinja2 import Environment, Template
from ks_includes.KlippyWebsocket import KlippyWebsocket from ks_includes.KlippyWebsocket import KlippyWebsocket
from ks_includes.KlippyRest import KlippyRest from ks_includes.KlippyRest import KlippyRest
@@ -440,6 +441,14 @@ class KlipperScreen(Gtk.Window):
{"name":_("Cancel"),"response": Gtk.ResponseType.CANCEL} {"name":_("Cancel"),"response": Gtk.ResponseType.CANCEL}
] ]
try:
env = Environment(extensions=["jinja2.ext.i18n"])
env.install_gettext_translations(self.lang)
j2_temp = env.from_string(text)
text = j2_temp.render()
except:
logger.debug("Error parsing jinja for confirm_send_action")
label = Gtk.Label() label = Gtk.Label()
label.set_markup(text) label.set_markup(text)
label.set_hexpand(True) label.set_hexpand(True)