#
# Copyright (C) 2010 Stefanos Harhalakis
#
-# This file is part of mydays.
+# This file is part of maegirls.
#
-# mydays is free software: you can redistribute it and/or modify
+# maegirls is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
-# mydays is distributed in the hope that it will be useful,
+# maegirls is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with mydays. If not, see <http://www.gnu.org/licenses/>.
+# along with maegirls. If not, see <http://www.gnu.org/licenses/>.
#
# $Id: 0.py 2265 2010-02-21 19:16:26Z v13 $
import sys
import time
+import locale
from graph import DaysGraph
import config
self.editCycle.setRange(10,50)
self.editCurrent.setRange(1,50)
self.editCurrent.setWrapping(True)
- self.editCycle.setSuffix(" days")
+ self.editCycle.setSuffix(self.tr(" days"))
self.editCycle.valueChanged.connect(self.slotEditCycleChanged)
self.l0=QHBoxLayout(self)
l1=QFormLayout()
- l1.addRow("Name:", self.editName)
- l1.addRow("Cycle length:", self.editCycle)
- l1.addRow("Current day in cycle:", self.editCurrent)
+ l1.addRow(self.tr("Name:"), self.editName)
+ l1.addRow(self.tr("Cycle length:"), self.editCycle)
+ l1.addRow(self.tr("Current day in cycle:"), self.editCurrent)
self.l0.addLayout(l1)
self.l0.addLayout(l2)
self.buttonOk=QPushButton(self)
- self.buttonOk.setText("OK")
+ self.buttonOk.setText(self.tr("OK"))
self.buttonOk.clicked.connect(self.slotButOk)
l2.addWidget(self.buttonOk)
spacer=QSpacerItem(20, 20, QSizePolicy.Minimum,QSizePolicy.Expanding)
l2.addItem(spacer)
- self.setWindowTitle("Configuration")
+ self.setWindowTitle(self.tr("Configuration"))
def slotButOk(self):
self.name=str(self.editName.text())
def __init__(self, *args, **kwargs):
MyMsgDialog.__init__(self, *args, **kwargs)
- txt="""
+ txt=self.tr("""
<p> A program to monitor the women's cycle. Good for planning (or acting ;-).
Inspired by "MyGirls" app which is (was?) available for Java ME capable phones.
<p> This program can be distributed under the terms of the GNU public
license, version 3 or any later.
- """
+ """)
- self.setWindowTitle("About MaeGirls")
+ self.setWindowTitle(self.tr("About MaeGirls"))
- self.ltitle=QLabel("MaeGirls", self.w)
+ self.ltitle=QLabel("MaeGirls v" + config.version, self.w)
self.ltitle.setObjectName("title")
self.ltitle.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
self.ltitle.setAlignment(Qt.AlignCenter)
def __init__(self, *args, **kwargs):
MyMsgDialog.__init__(self, *args, **kwargs)
- txt="""
+ txt=self.tr("""
<p> MaeGirls shows information about women's cycle using some generic
-guidelines. It assumes that the ovolution happens 14 days before the start
+guidelines. It assumes that the ovulation happens 14 days before the start
of the next period and that the period cycle is constant. Also, it assumes
that sperm can live for 4 days, while an egg can live for 2 days.
<p> Navigation is easy: Use left-right finger movement to move the calendar
view. Use up-down finger movement to zoom in/out.
- """
+ """)
- self.setWindowTitle("Help")
+ self.setWindowTitle(self.tr("Help"))
self.label=QLabel(txt, self.w)
self.label.setWordWrap(True)
self.l0.addWidget(self.lst)
self.buttonNew=QPushButton(self)
- self.buttonNew.setText("New")
+ self.buttonNew.setText(self.tr("New"))
self.buttonSelect=QPushButton(self)
- self.buttonSelect.setText("Select")
+ self.buttonSelect.setText(self.tr("Select"))
self.buttonDelete=QPushButton(self)
- self.buttonDelete.setText("Delete")
+ self.buttonDelete.setText(self.tr("Delete"))
spacer=QSpacerItem(20, 20, QSizePolicy.Minimum,QSizePolicy.Expanding)
# The selection works but isn't shown
idx2=self.lstm.index(idx, 0)
self.lst.setCurrentIndex(idx2)
+ # Give if focus to show the current selection - is this normal?
+ self.lst.setFocus(Qt.OtherFocusReason)
# Run
QDialog.exec_(self)
self.setupUi(algo)
- self.dlgConfig=ConfigDialog(self)
- self.dlgAbout=AboutDialog(self)
- self.dlgHelp=HelpDialog(self)
+# self.dlgConfig=ConfigDialog(self)
+# self.dlgAbout=AboutDialog(self)
+# self.dlgHelp=HelpDialog(self)
+ self.dlgConfig=None
+ self.dlgAbout=None
+ self.dlgHelp=None
self.dlgGirls=None
self.algo=algo
self.l0.addWidget(self.dg)
# Menu
- self.menuconfig=QAction('Configure', self)
+ self.menuconfig=QAction(self.tr('Configure'), self)
self.menuconfig.triggered.connect(self.menuConfig)
- self.menureset=QAction('Go to today', self)
+ self.menureset=QAction(self.tr('Go to today'), self)
self.menureset.triggered.connect(self.menuReset)
- self.menugirls=QAction('Girls', self)
+ self.menugirls=QAction(self.tr('Girls'), self)
self.menugirls.triggered.connect(self.menuGirls)
- self.menuabout=QAction('About', self)
+ self.menuabout=QAction(self.tr('About'), self)
self.menuabout.triggered.connect(self.menuAbout)
- self.menuhelp=QAction('Help', self)
+ self.menuhelp=QAction(self.tr('Help'), self)
self.menuhelp.triggered.connect(self.menuHelp)
m=self.menuBar()
- m.addAction(self.menuconfig)
m.addAction(self.menureset)
+ m.addAction(self.menuconfig)
m.addAction(self.menugirls)
m.addAction(self.menuhelp)
m.addAction(self.menuabout)
elif what=='delete' and which!=None:
if self.girl==which:
msg=QMessageBox(self)
- msg.setText("You cannot delete the current girl")
+ msg.setText(self.tr('You cannot delete the current girl'))
msg.exec_()
else:
config.removeGirl(which)
def init(algo):
global app
global win
+ global qttr, maetr
+ # Create the application
app=QApplication(sys.argv)
+
+ # This returns the country and *NOT* the required locale
+ # This means that if you have'set language==en_GB and countr==Greece
+ # it will return el_GR.
+ # IOW: If you want english messages this will not work
+ #loc=QLocale.system().name()
+
+ loc=locale.setlocale(locale.LC_MESSAGES, '')
+
+ print "loc:", loc
+
+ # Load translations
+ qttr=QTranslator()
+ qttr.load("qt_" + loc,
+ QLibraryInfo.location(QLibraryInfo.TranslationsPath))
+ app.installTranslator(qttr)
+
+ maetr=QTranslator()
+ maetr.load("maegirls_" + loc,
+ "/usr/share/maegirls/translations")
+
+ # Install the translation
+ app.installTranslator(maetr)
+
+ # One day support portrait mode
#app.setAttribute(Qt.WA_Maemo5PortraitOrientation, True);
+
+ # Create the main window
win=MaeGirls(algo)
win.show()