Verbesserungen in Sprachdatei "hu_HU.ts" + Laden von Zahlen aus der .CSV-Datei als Zahlenwerte, nicht Text
This commit is contained in:
parent
fb88dac713
commit
f1123a6fd5
4 changed files with 57 additions and 31 deletions
|
@ -1,5 +1,13 @@
|
|||
# Changelog GarageCalc1
|
||||
|
||||
## [0.5.2] - 2021-07-02
|
||||
## Changed
|
||||
- Verbesserungen in Sprachdatei "hu_HU.ts"
|
||||
|
||||
## [0.5.1] - 2021-07-02
|
||||
## Fixed
|
||||
- Laden von Zahlen aus der .CSV-Datei als Zahlenwerte, nicht Text
|
||||
|
||||
## [0.5] - 2021-07-02
|
||||
## Added
|
||||
- Tabelle "Gegenstände": Zeilen sind sortierbar (-> Klick auf Spaltenköpfe)
|
||||
|
|
BIN
i18n/hu_HU.qm
BIN
i18n/hu_HU.qm
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="de_DE">
|
||||
<context>
|
||||
|
@ -6,12 +6,12 @@
|
|||
<message>
|
||||
<location filename="clsTableWidget.py" line="87"/>
|
||||
<source>Cut</source>
|
||||
<translation>Vágd ki</translation>
|
||||
<translation>kivágni</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="clsTableWidget.py" line="88"/>
|
||||
<source>Copy</source>
|
||||
<translation>Vettem</translation>
|
||||
<translation>másolás</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="clsTableWidget.py" line="89"/>
|
||||
|
@ -21,7 +21,7 @@
|
|||
<message>
|
||||
<location filename="clsTableWidget.py" line="258"/>
|
||||
<source>Delete</source>
|
||||
<translation>Törölje</translation>
|
||||
<translation>Törlés</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="clsTableWidget.py" line="108"/>
|
||||
|
|
72
src/main.py
72
src/main.py
|
@ -28,7 +28,7 @@ from utils import show_about, resource_path
|
|||
from clsTableWidget import TableWidget
|
||||
|
||||
# Local globals
|
||||
APP_VERSION = "v0.5"
|
||||
APP_VERSION = "v0.5.2"
|
||||
|
||||
DIR_APPDATA = os.getenv('LOCALAPPDATA')
|
||||
|
||||
|
@ -70,11 +70,15 @@ WIN_HEIGHT = 640
|
|||
|
||||
TXT_UNSAVED_CHANGES = QCoreApplication.translate("main", "There are unsaved entries. Without saving, all changes are lost. Continue anyway?")
|
||||
|
||||
CONFIG = configparser.ConfigParser()
|
||||
TRANSLATOR = QTranslator()
|
||||
|
||||
####################################################################
|
||||
def main():
|
||||
qApp = QApplication(sys.argv)
|
||||
|
||||
global APP_NAME
|
||||
global APP_NAME, CONFIG, TRANSLATOR
|
||||
|
||||
qApp.setApplicationName(APP_NAME)
|
||||
qApp.setApplicationDisplayName(APP_DISPNAME)
|
||||
qApp.setApplicationVersion(APP_VERSION)
|
||||
|
@ -84,34 +88,30 @@ def main():
|
|||
qApp.setWindowIcon(QIcon(APP_ICON))
|
||||
qApp.setDesktopFileName(APP_DESKTOPFILENAME)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
language = "Deutsch"
|
||||
|
||||
if os.path.exists(os.path.join(DIR_APPDATA, APP_DISPNAME, APP_DISPNAME + '.ini')):
|
||||
config.read(os.path.join(DIR_APPDATA, APP_DISPNAME, APP_DISPNAME + '.ini'))
|
||||
language = config['DEFAULT']['language']
|
||||
CONFIG.read(os.path.join(DIR_APPDATA, APP_DISPNAME, APP_DISPNAME + '.ini'))
|
||||
language = CONFIG['DEFAULT']['language']
|
||||
else:
|
||||
config['DEFAULT']['language'] = language
|
||||
CONFIG['DEFAULT']['language'] = language
|
||||
if not os.path.exists(os.path.join(DIR_APPDATA, APP_DISPNAME)):
|
||||
os.makedirs(os.path.join(DIR_APPDATA, APP_DISPNAME))
|
||||
|
||||
with open(os.path.join(DIR_APPDATA, APP_DISPNAME, APP_DISPNAME + '.ini'), 'w') as configfile: # save
|
||||
config.write(configfile)
|
||||
|
||||
translator = QTranslator()
|
||||
CONFIG.write(configfile)
|
||||
|
||||
print("Current dir:", os.getcwd())
|
||||
if language == "Deutsch":
|
||||
print("Loading german language file.")
|
||||
translator.load(resource_path('./i18n/de_DE'))
|
||||
TRANSLATOR.load(resource_path('./i18n/de_DE'))
|
||||
elif language == "Magyar":
|
||||
print("Loading hungarian langauge file.")
|
||||
translator.load(resource_path('./i18n/hu_HU'))
|
||||
TRANSLATOR.load(resource_path('./i18n/hu_HU'))
|
||||
else:
|
||||
print(f"Unknown language setting '{language}' -> defaulting to english language.")
|
||||
|
||||
qApp.installTranslator(translator)
|
||||
qApp.installTranslator(TRANSLATOR)
|
||||
|
||||
app_name = qApp.translate("main", APP_NAME)
|
||||
qApp.setApplicationName(app_name)
|
||||
|
@ -258,7 +258,6 @@ class MainWindow(QMainWindow):
|
|||
|
||||
layoutGb.addWidget(self.ui.tableStuff)
|
||||
|
||||
|
||||
def create_actions(self):
|
||||
self.actionNew = QAction()
|
||||
self.actionNew.setIcon(QIcon(resource_path(ICON_NEW)))
|
||||
|
@ -369,6 +368,7 @@ class MainWindow(QMainWindow):
|
|||
if reply == QMessageBox.No:
|
||||
return False
|
||||
self.init_ui()
|
||||
self.ui.tableStuff.sortByColumn(-1) # reset sorting
|
||||
|
||||
def file_save(self):
|
||||
tblGarage = self.ui.tableGarage
|
||||
|
@ -515,6 +515,7 @@ class MainWindow(QMainWindow):
|
|||
options=options)
|
||||
if fileName:
|
||||
self.init_ui()
|
||||
self.ui.tableStuff.sortByColumn(-1) # reset sorting
|
||||
|
||||
file = open(fileName, "r", newline='')
|
||||
reader = csv.reader(file, delimiter=';')
|
||||
|
@ -528,9 +529,9 @@ class MainWindow(QMainWindow):
|
|||
garage_height = row[3]
|
||||
garage_comment = row[4]
|
||||
|
||||
tblGarage.setItem(0, COL_LENGTH-1, QTableWidgetItem(str(garage_length)))
|
||||
tblGarage.setItem(0, COL_WIDTH-1, QTableWidgetItem(str(garage_width)))
|
||||
tblGarage.setItem(0, COL_HEIGHT-1, QTableWidgetItem(str(garage_height)))
|
||||
tblGarage.setItem(0, COL_LENGTH-1, QTableWidgetItem(garage_length))
|
||||
tblGarage.setItem(0, COL_WIDTH-1, QTableWidgetItem(garage_width))
|
||||
tblGarage.setItem(0, COL_HEIGHT-1, QTableWidgetItem(garage_height))
|
||||
tblGarage.setItem(0, COL_COMMENT-1, QTableWidgetItem(garage_comment))
|
||||
|
||||
except IndexError as ex:
|
||||
|
@ -546,10 +547,26 @@ class MainWindow(QMainWindow):
|
|||
stuff_comment = row[5]
|
||||
|
||||
tblStuff.setItem(row_idx - 1, COL_STUFF, QTableWidgetItem(stuff))
|
||||
tblStuff.setItem(row_idx - 1, COL_LENGTH, QTableWidgetItem(str(stuff_length)))
|
||||
tblStuff.setItem(row_idx - 1, COL_WIDTH, QTableWidgetItem(str(stuff_width)))
|
||||
tblStuff.setItem(row_idx - 1, COL_HEIGHT, QTableWidgetItem(str(stuff_height)))
|
||||
tblStuff.setItem(row_idx - 1, COL_WEIGHT, QTableWidgetItem(str(stuff_weight)))
|
||||
|
||||
item = QTableWidgetItem()
|
||||
item.setData(Qt.DisplayRole, float(stuff_length))
|
||||
tblStuff.setItem(row_idx - 1, COL_LENGTH, item)
|
||||
|
||||
# tblStuff.setItem(row_idx - 1, COL_WIDTH, QTableWidgetItem(float(stuff_width)))
|
||||
item = QTableWidgetItem()
|
||||
item.setData(Qt.DisplayRole, float(stuff_width))
|
||||
tblStuff.setItem(row_idx - 1, COL_WIDTH, item)
|
||||
|
||||
#tblStuff.setItem(row_idx - 1, COL_HEIGHT, QTableWidgetItem(float(stuff_height)))
|
||||
item = QTableWidgetItem(stuff_height)
|
||||
item.setData(Qt.DisplayRole, float(stuff_height))
|
||||
tblStuff.setItem(row_idx - 1, COL_HEIGHT, item)
|
||||
|
||||
# tblStuff.setItem(row_idx - 1, COL_WEIGHT, QTableWidgetItem(float(stuff_weight)))
|
||||
item = QTableWidgetItem(stuff_weight)
|
||||
item.setData(Qt.DisplayRole, float(stuff_weight))
|
||||
tblStuff.setItem(row_idx - 1, COL_WEIGHT, item)
|
||||
|
||||
tblStuff.setItem(row_idx - 1, COL_COMMENT, QTableWidgetItem(stuff_comment))
|
||||
|
||||
except IndexError as ex:
|
||||
|
@ -871,6 +888,7 @@ class MainWindow(QMainWindow):
|
|||
def store_selected_language(self, menu):
|
||||
""" Stores selected menu labels to ini-file. """
|
||||
# [print(action.text()) for action in menu.actions() if action.isChecked()]
|
||||
global CONFIG
|
||||
|
||||
print("Current dir:", os.getcwd())
|
||||
language = "English"
|
||||
|
@ -878,23 +896,23 @@ class MainWindow(QMainWindow):
|
|||
if action.isChecked():
|
||||
language = action.text()
|
||||
|
||||
config['DEFAULT']['language'] = language
|
||||
CONFIG['DEFAULT']['language'] = language
|
||||
if not os.path.exists(os.path.join(DIR_APPDATA, APP_DISPNAME)):
|
||||
os.makedirs(os.path.join(DIR_APPDATA, APP_DISPNAME))
|
||||
|
||||
with open(os.path.join(DIR_APPDATA, APP_DISPNAME, APP_DISPNAME + '.ini'), 'w') as configfile: # save
|
||||
config.write(configfile)
|
||||
CONFIG.write(configfile)
|
||||
|
||||
if language == "Deutsch":
|
||||
print("Loading german language file.")
|
||||
translator.load(resource_path('./i18n/de_DE'))
|
||||
TRANSLATOR.load(resource_path('./i18n/de_DE'))
|
||||
elif language == "Magyar":
|
||||
print("Loading hungarian langauge file.")
|
||||
translator.load(resource_path('./i18n/hu_HU'))
|
||||
TRANSLATOR.load(resource_path('./i18n/hu_HU'))
|
||||
|
||||
else:
|
||||
#qApp.removeTranslator(translator)
|
||||
translator.load("dummy")
|
||||
print(f"Unknown language setting '{language}' -> defaulting to english language.")
|
||||
TRANSLATOR.load("dummy")
|
||||
|
||||
self.retranslateUi()
|
||||
|
||||
|
|
Loading…
Reference in a new issue