From 934d9710022fd2d484babc3a014866f363a77208 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 7 Mar 2019 18:04:11 +0200 Subject: [PATCH] - WIP for internationalization --- FlatCAMApp.py | 6 ------ README.md | 1 + flatcamTools/ToolCalculators.py | 4 ++++ flatcamTools/ToolCutOut.py | 5 +++++ flatcamTools/ToolDblSided.py | 4 ++++ flatcamTools/ToolFilm.py | 4 ++++ flatcamTools/ToolImage.py | 4 ++++ flatcamTools/ToolMeasurement.py | 4 ++++ flatcamTools/ToolMove.py | 4 ++++ flatcamTools/ToolNonCopperClear.py | 4 ++++ flatcamTools/ToolPaint.py | 4 ++++ flatcamTools/ToolPanelize.py | 4 ++++ flatcamTools/ToolProperties.py | 4 ++++ flatcamTools/ToolShell.py | 4 ++++ flatcamTools/ToolSolderPaste.py | 4 ++++ flatcamTools/ToolTransform.py | 4 ++++ locale/__init__.py | 1 + 17 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 locale/__init__.py diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 1554e910..e3687e0e 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -278,10 +278,6 @@ class App(QtCore.QObject): self.FC_light_blue = '#a5a5ffbf' self.FC_dark_blue = '#0000ffbf' - # needs to install the app default language before the GUI is initialized otherwise we get errors - # because FlatCAM will not understand the _() funtion - self.on_language_apply(lang='English') - QtCore.QObject.__init__(self) self.ui = FlatCAMGUI(self.version, self.beta, self) @@ -3278,8 +3274,6 @@ class App(QtCore.QObject): :return: """ - self.report_usage("on_language_apply()") - name = '' if lang is None: diff --git a/README.md b/README.md index e12f2140..3bc210e5 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ CAD program, and create G-Code for Isolation routing. - made showing a shape when hovering over objects, optional, by adding a Preferences -> General parameter - starting to work in internationalization using gettext() - Finished adding _() in FlatCAM Tools +- 6.03.2019 diff --git a/flatcamTools/ToolCalculators.py b/flatcamTools/ToolCalculators.py index b5763184..75fa0b19 100644 --- a/flatcamTools/ToolCalculators.py +++ b/flatcamTools/ToolCalculators.py @@ -3,6 +3,10 @@ from GUIElements import FCEntry from FlatCAMTool import FlatCAMTool from FlatCAMObj import * import math +import gettext + +def _(text): + return text class ToolCalculator(FlatCAMTool): diff --git a/flatcamTools/ToolCutOut.py b/flatcamTools/ToolCutOut.py index 58816d0e..44e06a82 100644 --- a/flatcamTools/ToolCutOut.py +++ b/flatcamTools/ToolCutOut.py @@ -2,6 +2,11 @@ from FlatCAMTool import FlatCAMTool from ObjectCollection import * from FlatCAMApp import * from shapely.geometry import box +import gettext + +def _(text): + return text + class CutOut(FlatCAMTool): diff --git a/flatcamTools/ToolDblSided.py b/flatcamTools/ToolDblSided.py index d17b8611..9bfc1e22 100644 --- a/flatcamTools/ToolDblSided.py +++ b/flatcamTools/ToolDblSided.py @@ -5,6 +5,10 @@ from FlatCAMObj import * from shapely.geometry import Point from shapely import affinity from PyQt5 import QtCore +import gettext + +def _(text): + return text class DblSidedTool(FlatCAMTool): diff --git a/flatcamTools/ToolFilm.py b/flatcamTools/ToolFilm.py index 9a3bfe1f..3be75efb 100644 --- a/flatcamTools/ToolFilm.py +++ b/flatcamTools/ToolFilm.py @@ -2,6 +2,10 @@ from FlatCAMTool import FlatCAMTool from GUIElements import RadioSet, FCEntry from PyQt5 import QtGui, QtCore, QtWidgets +import gettext + +def _(text): + return text class Film(FlatCAMTool): diff --git a/flatcamTools/ToolImage.py b/flatcamTools/ToolImage.py index f89f38f6..f1993a94 100644 --- a/flatcamTools/ToolImage.py +++ b/flatcamTools/ToolImage.py @@ -2,6 +2,10 @@ from FlatCAMTool import FlatCAMTool from GUIElements import RadioSet, FloatEntry, FCComboBox, IntEntry from PyQt5 import QtGui, QtCore, QtWidgets +import gettext + +def _(text): + return text class ToolImage(FlatCAMTool): diff --git a/flatcamTools/ToolMeasurement.py b/flatcamTools/ToolMeasurement.py index 8f12bc3f..e84abac1 100644 --- a/flatcamTools/ToolMeasurement.py +++ b/flatcamTools/ToolMeasurement.py @@ -4,6 +4,10 @@ from VisPyVisuals import * from copy import copy from math import sqrt +import gettext + +def _(text): + return text class Measurement(FlatCAMTool): diff --git a/flatcamTools/ToolMove.py b/flatcamTools/ToolMove.py index bea90d84..00acb241 100644 --- a/flatcamTools/ToolMove.py +++ b/flatcamTools/ToolMove.py @@ -4,6 +4,10 @@ from VisPyVisuals import * from io import StringIO from copy import copy +import gettext + +def _(text): + return text class ToolMove(FlatCAMTool): diff --git a/flatcamTools/ToolNonCopperClear.py b/flatcamTools/ToolNonCopperClear.py index 4e4fddde..28bf8874 100644 --- a/flatcamTools/ToolNonCopperClear.py +++ b/flatcamTools/ToolNonCopperClear.py @@ -2,6 +2,10 @@ from FlatCAMTool import FlatCAMTool from copy import copy,deepcopy from ObjectCollection import * import time +import gettext + +def _(text): + return text class NonCopperClear(FlatCAMTool, Gerber): diff --git a/flatcamTools/ToolPaint.py b/flatcamTools/ToolPaint.py index 580af4fb..8fcbef97 100644 --- a/flatcamTools/ToolPaint.py +++ b/flatcamTools/ToolPaint.py @@ -1,6 +1,10 @@ from FlatCAMTool import FlatCAMTool from copy import copy,deepcopy from ObjectCollection import * +import gettext + +def _(text): + return text class ToolPaint(FlatCAMTool, Gerber): diff --git a/flatcamTools/ToolPanelize.py b/flatcamTools/ToolPanelize.py index 2b1161a3..44cc125f 100644 --- a/flatcamTools/ToolPanelize.py +++ b/flatcamTools/ToolPanelize.py @@ -2,6 +2,10 @@ from FlatCAMTool import FlatCAMTool from copy import copy, deepcopy from ObjectCollection import * import time +import gettext + +def _(text): + return text class Panelize(FlatCAMTool): diff --git a/flatcamTools/ToolProperties.py b/flatcamTools/ToolProperties.py index 282761de..2502ddb0 100644 --- a/flatcamTools/ToolProperties.py +++ b/flatcamTools/ToolProperties.py @@ -2,6 +2,10 @@ from PyQt5 import QtGui, QtCore, QtWidgets from PyQt5.QtCore import Qt from FlatCAMTool import FlatCAMTool from FlatCAMObj import * +import gettext + +def _(text): + return text class Properties(FlatCAMTool): diff --git a/flatcamTools/ToolShell.py b/flatcamTools/ToolShell.py index 374b6e67..937a997c 100644 --- a/flatcamTools/ToolShell.py +++ b/flatcamTools/ToolShell.py @@ -12,6 +12,10 @@ from PyQt5.QtGui import QTextCursor from PyQt5.QtWidgets import QVBoxLayout, QWidget from GUIElements import _BrowserTextEdit, _ExpandableTextEdit import html +import gettext + +def _(text): + return text class TermWidget(QWidget): diff --git a/flatcamTools/ToolSolderPaste.py b/flatcamTools/ToolSolderPaste.py index af87fb19..dc178052 100644 --- a/flatcamTools/ToolSolderPaste.py +++ b/flatcamTools/ToolSolderPaste.py @@ -16,6 +16,10 @@ from shapely.ops import cascaded_union import traceback from io import StringIO +import gettext + +def _(text): + return text class SolderPaste(FlatCAMTool): diff --git a/flatcamTools/ToolTransform.py b/flatcamTools/ToolTransform.py index e59d563e..889da5f4 100644 --- a/flatcamTools/ToolTransform.py +++ b/flatcamTools/ToolTransform.py @@ -3,6 +3,10 @@ from PyQt5.QtCore import Qt from GUIElements import FCEntry, FCButton, OptionalInputSection from FlatCAMTool import FlatCAMTool from FlatCAMObj import * +import gettext + +def _(text): + return text class ToolTransform(FlatCAMTool): diff --git a/locale/__init__.py b/locale/__init__.py new file mode 100644 index 00000000..fc80254b --- /dev/null +++ b/locale/__init__.py @@ -0,0 +1 @@ +pass \ No newline at end of file