from PySide2.QtCore import * from PySide2.QtWidgets import * from PySide2.QtGui import * from PySide2.QtPrintSupport import * from PySide2.QtUiTools import * import string from .Config import _ _("First page") # Context: QPrintPreviewDialog _("Fit page") # Context: QPrintPreviewDialog _("Fit width") # Context: QPrintPreviewDialog _("Landscape") # Context: QPrintPreviewDialog _("Last page") # Context: QPrintPreviewDialog _("Next page") # Context: QPrintPreviewDialog _("Page Setup") # Context: QPrintPreviewDialog _("Page setup") # Context: QPrintPreviewDialog _("Portrait") # Context: QPrintPreviewDialog _("Previous page") # Context: QPrintPreviewDialog _("Print Preview") # Context: QPrintPreviewDialog _("Show facing pages") # Context: QPrintPreviewDialog _("Show overview of all pages") # Context: QPrintPreviewDialog _("Show single page") # Context: QPrintPreviewDialog _("Zoom in") # Context: QPrintPreviewDialog _("Zoom out") # Context: QPrintPreviewDialog # Total strings = 15 _("&Cancel") # Context: KStandardGuiItem _("&Name:") # Context: QPrintWidget _("&OK") # Context: KStandardGuiItem _("&Options <<") # Context: QPrintDialog _("&Options >>") # Context: QPrintDialog _("&Print") # Context: QPrintDialog _("&Save") # Context: KStandardGuiItem _("--- separator ---") # Context: KBookmark _("...") # Context: QPrintWidget _("1") # Context: KLineEdit _("1 (1x1)") # Context: QPrintDialog _("16 (4x4)") # Context: QPrintDialog _("2 (2x1)") # Context: QPrintDialog _("4 (2x2)") # Context: QPrintDialog _("6 (2x3)") # Context: QPrintDialog _("9 (3x3)") # Context: QPrintDialog _("A0") # Context: QPageSize _("A1") # Context: QPageSize _("A10") # Context: QPageSize _("A2") # Context: QPageSize _("A3") # Context: QPageSize _("A3 Extra") # Context: QPageSize _("A4") # Context: QPageSize _("A4 Extra") # Context: QPageSize _("A4 Plus") # Context: QPageSize _("A4 Small") # Context: QPageSize _("A5") # Context: QPageSize _("A5 Extra") # Context: QPageSize _("A6") # Context: QPageSize _("A7") # Context: QPageSize _("A8") # Context: QPageSize _("A9") # Context: QPageSize _("ANSI C") # Context: QPageSize _("ANSI D") # Context: QPageSize _("ANSI E") # Context: QPageSize _("Advanced") # Context: QPrintPropertiesWidget _("All Files (*)") # Context: QFileDialog _("All Pages") # Context: QPrintDialog _("Architect A") # Context: QPageSize _("Architect B") # Context: QPageSize _("Architect C") # Context: QPageSize _("Architect D") # Context: QPageSize _("Architect E") # Context: QPageSize _("B0") # Context: QPageSize _("B1") # Context: QPageSize _("B10") # Context: QPageSize _("B2") # Context: QPageSize _("B3") # Context: QPageSize _("B4") # Context: QPageSize _("B5") # Context: QPageSize _("B5 Extra") # Context: QPageSize _("B6") # Context: QPageSize _("B7") # Context: QPageSize _("B8") # Context: QPageSize _("B9") # Context: QPageSize _("Banner Pages") # Context: QCupsJobWidget _("Billing information:") # Context: QCupsJobWidget _("Bottom to Top, Left to Right") # Context: QPrintDialog _("Bottom to Top, Right to Left") # Context: QPrintDialog _("Cicero (CC)") # Context: QPageSetupWidget _("Classified") # Context: QCupsJobWidget _("Closes the dock widget") # Context: QDockWidget _("Collate") # Context: QPrintSettingsOutput _("Color") # Context: QPrintSettingsOutput _("Color Mode") # Context: QPrintSettingsOutput _("Computer") # Context: QFileSystemModel _("Confidential") # Context: QCupsJobWidget _("Copies") # Context: QPrintSettingsOutput _("Copies:") # Context: QPrintSettingsOutput _("Current Page") # Context: QPrintSettingsOutput _("Custom") # Context: QPageSetupWidget _("Day (06:00 to 17:59)") # Context: QCupsJobWidget _("Didot (DD)") # Context: QPageSetupWidget _("Double Postcard") # Context: QPageSize _("Drive") # Context: QFileDialog _("Duplex Printing") # Context: QPrintSettingsOutput _("End:") # Context: QCupsJobWidget _("Envelope B4") # Context: QPageSize _("Envelope B5") # Context: QPageSize _("Envelope B6") # Context: QPageSize _("Envelope C0") # Context: QPageSize _("Envelope C1") # Context: QPageSize _("Envelope C2") # Context: QPageSize _("Envelope C3") # Context: QPageSize _("Envelope C4") # Context: QPageSize _("Envelope C5") # Context: QPageSize _("Envelope C6") # Context: QPageSize _("Envelope C65") # Context: QPageSize _("Envelope C7") # Context: QPageSize _("Envelope Chou 3") # Context: QPageSize _("Envelope Chou 4") # Context: QPageSize _("Envelope DL") # Context: QPageSize _("Envelope Invite") # Context: QPageSize _("Envelope Italian") # Context: QPageSize _("Envelope Kaku 2") # Context: QPageSize _("Envelope Kaku 3") # Context: QPageSize _("Envelope Monarch") # Context: QPageSize _("Envelope PRC 1") # Context: QPageSize _("Envelope PRC 10") # Context: QPageSize _("Envelope PRC 2") # Context: QPageSize _("Envelope PRC 3") # Context: QPageSize _("Envelope PRC 4") # Context: QPageSize _("Envelope PRC 5") # Context: QPageSize _("Envelope PRC 6") # Context: QPageSize _("Envelope PRC 7") # Context: QPageSize _("Envelope PRC 8") # Context: QPageSize _("Envelope PRC 9") # Context: QPageSize _("Envelope Personal") # Context: QPageSize _("Envelope US 10") # Context: QPageSize _("Envelope US 11") # Context: QPageSize _("Envelope US 12") # Context: QPageSize _("Envelope US 14") # Context: QPageSize _("Envelope US 9") # Context: QPageSize _("Even Pages") # Context: QPrintDialog _("Executive (7.25 x 10.5 in)") # Context: QPageSize _("Executive (7.5 x 10 in)") # Context: QPageSize _("Fan-fold German (8.5 x 12 in)") # Context: QPageSize _("Fan-fold German Legal (8.5 x 13 in)") # Context: QPageSize _("Fan-fold US (14.875 x 11 in)") # Context: QPageSize _("File not found") # Context: QImageReader _("Float") # Context: QDockWidget _("Folder") # Context: QFileDialog _("Folio (8.27 x 13 in)") # Context: QPageSize _("Form") # Context: QPageSetupWidget _("Grayscale") # Context: QPrintSettingsOutput _("Height:") # Context: QPageSetupWidget _("Hold Indefinitely") # Context: QCupsJobWidget _("Inches (in)") # Context: QPageSetupWidget _("JIS B0") # Context: QPageSize _("JIS B1") # Context: QPageSize _("JIS B10") # Context: QPageSize _("JIS B2") # Context: QPageSize _("JIS B3") # Context: QPageSize _("JIS B4") # Context: QPageSize _("JIS B5") # Context: QPageSize _("JIS B6") # Context: QPageSize _("JIS B7") # Context: QPageSize _("JIS B8") # Context: QPageSize _("JIS B9") # Context: QPageSize _("Job") # Context: QCupsJobWidget _("Job Control") # Context: QCupsJobWidget _("Job Options") # Context: QPrintPropertiesDialog _("Job priority:") # Context: QCupsJobWidget _("Ledger / ANSI B") # Context: QPageSize _("Left to Right, Bottom to Top") # Context: QPrintDialog _("Left to Right, Top to Bottom") # Context: QPrintDialog _("Legal") # Context: QPageSize _("Legal Extra") # Context: QPageSize _("Letter / ANSI A") # Context: QPageSize _("Letter Extra") # Context: QPageSize _("Letter Plus") # Context: QPageSize _("Letter Small") # Context: QPageSize _("Location:") # Context: QPrintWidget _("Long side") # Context: QPrintSettingsOutput _("Margins") # Context: QPageSetupWidget _("Millimeters (mm)") # Context: QPageSetupWidget _("Night (18:00 to 05:59)") # Context: QCupsJobWidget _("None") # Context: QPrintSettingsOutput _("Note") # Context: QPageSize _("Odd Pages") # Context: QPrintDialog _("Options") # Context: QPrintSettingsOutput _("Orientation") # Context: QPageSetupWidget _("Output &file:") # Context: QPrintWidget _("Output Settings") # Context: QPrintSettingsOutput _("P&roperties") # Context: QPrintWidget _("PRC 16K") # Context: QPageSize _("PRC 32K") # Context: QPageSize _("PRC 32K Big") # Context: QPageSize _("Page") # Context: QPrintPropertiesWidget _("Page Layout") # Context: QPageSetupWidget _("Page Set:") # Context: QPrintSettingsOutput _("Page order:") # Context: QPageSetupWidget _("Page size:") # Context: QPageSetupWidget _("Pages") # Context: QPrintSettingsOutput _("Pages from") # Context: QPrintSettingsOutput _("Pages per sheet:") # Context: QPageSetupWidget _("Paper") # Context: QPageSetupWidget _("Paper source:") # Context: QPageSetupWidget _("Pica (P̸)") # Context: QPageSetupWidget _("Points (pt)") # Context: QPageSetupWidget _("Postcard") # Context: QPageSize _("Preview") # Context: QPrintWidget _("Print Immediately") # Context: QCupsJobWidget _("Print To File ...") # Context: QPrintDialog _("Print all") # Context: QPrintSettingsOutput _("Print range") # Context: QPrintSettingsOutput _("Print to File (PDF)") # Context: QPrintDialog _("Printer") # Context: QPrintWidget _("Printer Properties") # Context: QPrintPropertiesDialog _("Quarto") # Context: QPageSize _("Reverse") # Context: QPrintSettingsOutput _("Reverse landscape") # Context: QPageSetupWidget _("Reverse portrait") # Context: QPageSetupWidget _("Right to Left, Bottom to Top") # Context: QPrintDialog _("Right to Left, Top to Bottom") # Context: QPrintDialog _("Save data") # Context: KStandardGuiItem _("Scheduled printing:") # Context: QCupsJobWidget _("Scroll Left") # Context: QTabBar _("Scroll Right") # Context: QTabBar _("Second Shift (16:00 to 23:59)") # Context: QCupsJobWidget _("Secret") # Context: QCupsJobWidget _("Selection") # Context: QPrintSettingsOutput _("Short side") # Context: QPrintSettingsOutput _("Specific Time") # Context: QCupsJobWidget _("Specify pages or ranges separated by commas. Ranges are specified by two numbers separated by a hyphen. E.g: 3,5-7,9 prints pages 3, 5, 6, 7 and 9.") # Context: QPrintSettingsOutput _("Standard") # Context: QCupsJobWidget _("Start:") # Context: QCupsJobWidget _("Statement") # Context: QPageSize _("Storage") # Context: Solid::Backends::UDisks2::Manager _("Storage devices") # Context: Solid::Backends::UDisks2::Manager _("Super A") # Context: QPageSize _("Super B") # Context: QPageSize _("Tabloid / ANSI B") # Context: QPageSize _("Tabloid Extra") # Context: QPageSize _("There are conflicts in some options. Please fix them.") # Context: QPrintPropertiesWidget _("Third Shift (00:00 to 07:59)") # Context: QCupsJobWidget _("Top Secret") # Context: QCupsJobWidget _("Top to Bottom, Left to Right") # Context: QPrintDialog _("Top to Bottom, Right to Left") # Context: QPrintDialog _("Type:") # Context: QPrintWidget _("Unclassified") # Context: QCupsJobWidget _("Undocks and re-attaches the dock widget") # Context: QDockWidget _("Unknown error") # Context: QImageWriter _("Weekend (Saturday to Sunday)") # Context: QCupsJobWidget _("Width:") # Context: QPageSetupWidget _("alert message") # Context: QSpiAccessibleBridge _("animation") # Context: QSpiAccessibleBridge _("application") # Context: QSpiAccessibleBridge _("assistant") # Context: QSpiAccessibleBridge _("bottom margin") # Context: QPageSetupWidget _("button menu") # Context: QSpiAccessibleBridge _("button with drop down") # Context: QSpiAccessibleBridge _("button with drop down grid") # Context: QSpiAccessibleBridge _("canvas") # Context: QSpiAccessibleBridge _("cell") # Context: QSpiAccessibleBridge _("chart") # Context: QSpiAccessibleBridge _("check box") # Context: QSpiAccessibleBridge _("clock") # Context: QSpiAccessibleBridge _("color chooser") # Context: QSpiAccessibleBridge _("column") # Context: QSpiAccessibleBridge _("column header") # Context: QSpiAccessibleBridge _("combo box") # Context: QSpiAccessibleBridge _("complementary content") # Context: QSpiAccessibleBridge _("cursor") # Context: QSpiAccessibleBridge _("desktop") # Context: QSpiAccessibleBridge _("dial") # Context: QSpiAccessibleBridge _("dialog") # Context: QSpiAccessibleBridge _("document") # Context: QSpiAccessibleBridge _("equation") # Context: QSpiAccessibleBridge _("filler") # Context: QSpiAccessibleBridge _("footer") # Context: QSpiAccessibleBridge _("form") # Context: QSpiAccessibleBridge _("frame") # Context: QSpiAccessibleBridge _("graphic") # Context: QSpiAccessibleBridge _("grip") # Context: QSpiAccessibleBridge _("heading") # Context: QSpiAccessibleBridge _("help balloon") # Context: QSpiAccessibleBridge _("hotkey field") # Context: QSpiAccessibleBridge _("indicator") # Context: QSpiAccessibleBridge _("invalid role") # Context: QSpiAccessibleBridge _("label") # Context: QSpiAccessibleBridge _("layered pane") # Context: QSpiAccessibleBridge _("left margin") # Context: QPageSetupWidget _("link") # Context: QSpiAccessibleBridge _("list") # Context: QSpiAccessibleBridge _("list item") # Context: QSpiAccessibleBridge _("menu bar") # Context: QSpiAccessibleBridge _("menu item") # Context: QSpiAccessibleBridge _("mm") # Context: QPageSetupWidget _("note") # Context: QSpiAccessibleBridge _("notification") # Context: QSpiAccessibleBridge _("page tab") # Context: QSpiAccessibleBridge _("page tab list") # Context: QSpiAccessibleBridge _("panel") # Context: QSpiAccessibleBridge _("paragraph") # Context: QSpiAccessibleBridge _("popup menu") # Context: QSpiAccessibleBridge _("progress bar") # Context: QSpiAccessibleBridge _("property page") # Context: QSpiAccessibleBridge _("push button") # Context: QSpiAccessibleBridge _("radio button") # Context: QSpiAccessibleBridge _("right margin") # Context: QPageSetupWidget _("row header") # Context: QSpiAccessibleBridge _("scroll bar") # Context: QSpiAccessibleBridge _("section") # Context: QSpiAccessibleBridge _("separator") # Context: QSpiAccessibleBridge _("slider") # Context: QSpiAccessibleBridge _("sound") # Context: QSpiAccessibleBridge _("space") # Context: QSpiAccessibleBridge _("spin box") # Context: QSpiAccessibleBridge _("splitter") # Context: QSpiAccessibleBridge _("status bar") # Context: QSpiAccessibleBridge _("table") # Context: QSpiAccessibleBridge _("terminal") # Context: QSpiAccessibleBridge _("text") # Context: QSpiAccessibleBridge _("text caret") # Context: QSpiAccessibleBridge _("title bar") # Context: QSpiAccessibleBridge _("tool bar") # Context: QSpiAccessibleBridge _("tool tip") # Context: QSpiAccessibleBridge _("top margin") # Context: QPageSetupWidget _("tree") # Context: QSpiAccessibleBridge _("tree item") # Context: QSpiAccessibleBridge _("web document") # Context: QSpiAccessibleBridge # Total strings = 302 _("&Cancelar") # Context: KMessageBox _("&No") # Context: KStandardGuiItem _("&Overwrite") # Context: KStandardGuiItem _("&Yes") # Context: KStandardGuiItem _("A4") # Context: QPageSize _("No") # Context: KStandardGuiItem _("Yes") # Context: KStandardGuiItem _("cursor") # Context: QSpiAccessibleBridge _("dial") # Context: QSpiAccessibleBridge _("panel") # Context: QSpiAccessibleBridge _("terminal") # Context: QSpiAccessibleBridge class CustomTranslator(QTranslator): def __init__(self,*args,**kwargs): self.debug = kwargs.get('debug') super().__init__(*args) self.mapping = {} def printAcumulatedPythonStrings(self): if self.debug: def print_list(keylist,mapping,commented=False): if commented: qDebug("'''") for x in keylist: qDebug('_("{}") # Context: {}'.format(x,mapping[x])) qDebug("# {} = {}\n".format(_('Total strings'),len(keylist))) if commented: qDebug("'''") keys = [] keysPrintPreview = [] other = [] for key,context in self.mapping.items(): if '%' in key: other.append(key) elif 'qprintpreview' in context.lower(): keysPrintPreview.append(key) else: keys.append(key) keys = sorted(keys) keysPrintPreview = sorted(keysPrintPreview) print_list(keysPrintPreview,self.mapping) print_list(keys,self.mapping) print_list(other,self.mapping,True) def translate(self, *args, **kwargs): context = args[0] source = args[1] translated_gettext = _(source) translated_qt = super().translate(*args) translated = translated_gettext if translated_gettext == source: if translated_qt and translated_qt != source: translated = translated_qt if self.debug: if translated == source: if source.isalpha() or source.translate({ord('&'):65,ord(' '):65}).isalpha(): self.mapping.setdefault(source, context) qDebug('{}:{} ("{}" -> "{}") '.format(_('Warning'),_('Possible missing translation'),source,translated)) return translated