From 9eb3560cfd5cd0bc9c7bf79f2c27657ee07b8f95 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Sat, 8 Aug 2009 14:40:25 +0200 Subject: [PATCH 12/13] Add context to tr calls in QShortcut Some languages have special rules for using "+" to concatenate strings and for example it needs to be Ctrl + Shift instead of Ctrl+Shift, adding context to these strings helps creating a more correct translation --- src/gui/kernel/qkeysequence.cpp | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 894f663..c17f253 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -991,10 +991,10 @@ int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::Sequence QList modifs; if (nativeText) { - modifs << QModifKeyName(Qt::CTRL, QShortcut::tr("Ctrl").toLower().append(QLatin1Char('+'))) - << QModifKeyName(Qt::SHIFT, QShortcut::tr("Shift").toLower().append(QLatin1Char('+'))) - << QModifKeyName(Qt::ALT, QShortcut::tr("Alt").toLower().append(QLatin1Char('+'))) - << QModifKeyName(Qt::META, QShortcut::tr("Meta").toLower().append(QLatin1Char('+'))); + modifs << QModifKeyName(Qt::CTRL, QShortcut::tr("Ctrl", "Ctrl key, used for shortcuts").toLower().append(QLatin1Char('+'))) + << QModifKeyName(Qt::SHIFT, QShortcut::tr("Shift", "Shift key, used for shortcuts").toLower().append(QLatin1Char('+'))) + << QModifKeyName(Qt::ALT, QShortcut::tr("Alt", "Alt key, used for shortcuts").toLower().append(QLatin1Char('+'))) + << QModifKeyName(Qt::META, QShortcut::tr("Meta", "Meta key, used for shortcuts").toLower().append(QLatin1Char('+'))); } modifs += *gmodifs; // Test non-translated ones last @@ -1086,7 +1086,7 @@ QString QKeySequence::encodeString(int key) static inline void addKey(QString &str, const QString &theKey, QKeySequence::SequenceFormat format) { if (!str.isEmpty()) - str += (format == QKeySequence::NativeText) ? QShortcut::tr("+") + str += (format == QKeySequence::NativeText) ? QShortcut::tr("+", "Symbol used to concatenate keys in shortcuts") : QString::fromLatin1("+"); str += theKey; } @@ -1111,13 +1111,13 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat { // On other systems the order is Meta, Control, Alt, Shift if ((key & Qt::META) == Qt::META) - s = nativeText ? QShortcut::tr("Meta") : QString::fromLatin1("Meta"); + s = nativeText ? QShortcut::tr("Meta", "Meta key, used for shortcuts") : QString::fromLatin1("Meta"); if ((key & Qt::CTRL) == Qt::CTRL) - addKey(s, nativeText ? QShortcut::tr("Ctrl") : QString::fromLatin1("Ctrl"), format); + addKey(s, nativeText ? QShortcut::tr("Ctrl", "Ctrl key, used for shortcuts") : QString::fromLatin1("Ctrl"), format); if ((key & Qt::ALT) == Qt::ALT) - addKey(s, nativeText ? QShortcut::tr("Alt") : QString::fromLatin1("Alt"), format); + addKey(s, nativeText ? QShortcut::tr("Alt", "Alt key, used for shortcuts") : QString::fromLatin1("Alt"), format); if ((key & Qt::SHIFT) == Qt::SHIFT) - addKey(s, nativeText ? QShortcut::tr("Shift") : QString::fromLatin1("Shift"), format); + addKey(s, nativeText ? QShortcut::tr("Shift", "Shift key, used for shortcuts") : QString::fromLatin1("Shift"), format); } @@ -1132,7 +1132,7 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat p += QChar((key-0x10000)%400+0xdc00); } } else if (key >= Qt::Key_F1 && key <= Qt::Key_F35) { - p = nativeText ? QShortcut::tr("F%1").arg(key - Qt::Key_F1 + 1) + p = nativeText ? QShortcut::tr("F%1", "Fx key, used for shortcuts").arg(key - Qt::Key_F1 + 1) : QString::fromLatin1("F%1").arg(key - Qt::Key_F1 + 1); } else if (key) { int i=0; -- 1.6.5.1