Diffstat (limited to 'core/pim/datebook/repeatentry.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/repeatentry.cpp | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/core/pim/datebook/repeatentry.cpp b/core/pim/datebook/repeatentry.cpp index 5637c4d..b1a162d 100644 --- a/core/pim/datebook/repeatentry.cpp +++ b/core/pim/datebook/repeatentry.cpp @@ -24,65 +24,87 @@ #include <qpe/qpeapplication.h> #include <qpe/timestring.h> #include <qbuttongroup.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qspinbox.h> #include <qtoolbutton.h> #include <time.h> // Global Templates for use in setting up the repeat label... -const QString strDayTemplate = QObject::tr("Every"); -const QString strYearTemplate = QObject::tr("%1 %2 every "); -const QString strMonthDateTemplate = QObject::tr("The %1 every "); -const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every"); -const QString strWeekTemplate = QObject::tr("Every "); -const QString dayLabel[] = { QObject::tr("Monday"), - QObject::tr("Tuesday"), - QObject::tr("Wednesday"), - QObject::tr("Thursday"), - QObject::tr("Friday"), - QObject::tr("Saturday"), - QObject::tr("Sunday") }; +// the problem is these strings get initialized before QPEApplication can install the translator -zecke +namespace { +QString strDayTemplate; +QString strYearTemplate; +QString strMonthDateTemplate; +QString strMonthDayTemplate; +QString strWeekTemplate; +QString dayLabel[7]; +} +/* + * static linkage to not polute the symbol table... + * The problem is that const and static linkage are resolved prior to installing a translator + * leading to that the above strings are translted but to the original we delay the init of these strings... + * -zecke + */ +static void fillStrings() { + strDayTemplate = QObject::tr("Every"); + strYearTemplate = QObject::tr("%1 %2 every "); + strMonthDateTemplate = QObject::tr("The %1 every "); + strMonthDayTemplate = QObject::tr("The %1 %1 of every"); + strWeekTemplate = QObject::tr("Every "); + dayLabel[0] = QObject::tr("Monday"); + dayLabel[1] = QObject::tr("Tuesday"); + dayLabel[2] = QObject::tr("Wednesday"); + dayLabel[3] = QObject::tr("Thursday"); + dayLabel[4] = QObject::tr("Friday"); + dayLabel[5] = QObject::tr("Saturday"); + dayLabel[6] = QObject::tr("Sunday"); +} static QString numberPlacing( int x ); // return the proper word format for // x (1st, 2nd, etc) static int week( const QDate &dt ); // what week in the month is dt? RepeatEntry::RepeatEntry( bool startOnMonday, const QDate &newStart, QWidget *parent, const char *name, bool modal, WFlags fl ) : RepeatEntryBase( parent, name, modal, fl ), start( newStart ), currInterval( NONE ), startWeekOnMonday( startOnMonday ) { + if (strDayTemplate.isEmpty() ) + fillStrings(); + init(); fraType->setButton( currInterval ); chkNoEnd->setChecked( TRUE ); setupNone(); } RepeatEntry::RepeatEntry( bool startOnMonday, const Event::RepeatPattern &rp, const QDate &startDate, QWidget *parent, const char *name, bool modal, WFlags fl ) : RepeatEntryBase( parent, name, modal, fl ), start( startDate ), end( rp.endDate() ), startWeekOnMonday( startOnMonday ) { + if (strDayTemplate.isEmpty() ) + fillStrings(); // do some stuff with the repeat pattern init(); switch ( rp.type ) { default: case Event::NoRepeat: currInterval = NONE; setupNone(); break; case Event::Daily: currInterval = DAY; setupDaily(); break; @@ -397,25 +419,25 @@ void RepeatEntry::setupRepeatLabel( int x ) if ( x > 1 ) lblVar1->show(); else lblVar1->hide(); switch ( currInterval ) { case NONE: break; case DAY: if ( x > 1 ) strVar2 = tr( "days" ); else - strVar2 = tr( "day" ); + strVar2 = tr( "day" ); break; case WEEK: if ( x > 1 ) strVar2 = tr( "weeks" ); else strVar2 = tr( "week" ); break; case MONTH: if ( x > 1 ) strVar2 = RepeatEntryBase::tr( "months" ); else strVar2 = tr( "month" ); @@ -491,25 +513,25 @@ void RepeatEntry::slotWeekLabel() if ( bNeedCarriage ) str += tr( ",\nand " ) + *itStr; else str += tr( ", and " ) + *itStr; } } else { if ( bNeedCarriage ) str += ",\n" + *itStr; else str += ", " + *itStr; } } - str = str.prepend( "on " ); + str = str.prepend( tr("on ") ); lblWeekVar->setText( str ); } void RepeatEntry::slotMonthLabel( int type ) { QString str; if ( currInterval != MONTH || type > 1 ) return; if ( type == 1 ) str = strMonthDateTemplate.arg( numberPlacing(start.day()) ); else str = strMonthDayTemplate.arg( numberPlacing(week(start))) |