[Kde-games-devel] Hardcoded Quotation in KGoldrunner

Frederik Schwarzer schwarzerf at gmail.com
Fri May 22 01:05:00 CEST 2009


On Thursday 21. May 2009 22:53:03 Parker Coates wrote:
> On Thu, May 21, 2009 at 4:10 PM, Frederik Schwarzer wrote:
> > Hi,
> >
> > there is some oddness of the following code in src/kgoldrunner.cpp
> >
> >  887     // Now update the PAUSE/RESUME message in the status bar.
> >  888     kDebug() << "Update Pause/Resume message ...";
> >  889     pauseKeys = myPause->shortcut().toString(QKeySequence::NativeText);
> >  890     pauseKeys = pauseKeys.replace (';', "\" " + i18n ("or") + " \"");
> >  891     gameFreeze (frozen);»···»···// Refresh the status bar text.
> >
> > The string translators see is
> >    Press \"%1\" to PAUSE
> >
> > In German this is translated as
> >    Drücken Sie „%1“, um eine Pause zu machen
> >
> > Together with the above code, it looks like this in KDE 4.2:
> >    Drücken Sie „P" oder " ESC“, um eine Pause zu machen
> >
> > However, it looks like this in KDE 4.3:
> >    Drücken Sie „P“, um eine Pause zu machen
> >
> > The Shortcut settings are the same.
> >
> > So, what's going on here?
> > If it was changed for KDE 4.3 to only return the primary shortcut then the code
> > can be skipped. If there should be both shortcuts, the code is quite unfortunate
> > i18n-wise.
> >
> > Any Idea how to fix this issue?
> >
> > - pauseKeys = pauseKeys.replace (';', "\" " + i18n ("or") + " \"");
> > + pauseKeys = pauseKeys.replace ("; ", i18nc("closing quotation mark", "\" ") + i18n ("or") + i18nc("opening quotation mark"," \""));
> >
> > ... would probably make things better for translators ... but maybe
> > somebody can think of a proper solution.
> 
> Hey Frederik,
> 
> Solutions involving QString::replace() and i18n() generally scare me.

Indeed.


> Why not something like this:
> 
> QString message;
> QStringList l =
> action->shortcut().toString(QKeySequence::NativeText).split("; ");
> if ( l.size() == 1 )
> 	message = i18n("Press \"%1\" to PAUSE", l[0]);
> else if ( l.size() == 2 )
> 	message = i18n("Press \"%1\" or \"%2\" to PAUSE", l[0], l[1]);
> else
> 	message = i18n("Press \"%1\" or \"%2\" or \"%3\" to PAUSE", l[0], l[1], l[1]);
> 
> I doubt the third clause is necessary, but I threw it in for kicks. I
> realise this breaks the string freeze, but I'm sure translators would
> prefer it to the current mess.

I like your idea better. Maybe there are languages where it makes a difference
if there are on or two shortcuts.

But what's the third element? The global shortcut? The apidoc does not mention it.

QAction has a shortcuts() function, that returns a QList of QKeySequence.

But let Ian speak first. :)

Regards


More information about the kde-games-devel mailing list