refine more messages to use tr()

This commit is contained in:
Le Tan 2017-03-04 14:28:09 +08:00
parent 38b18af4ab
commit f46b023d1b
9 changed files with 181 additions and 33 deletions

View File

@ -38,7 +38,7 @@ void VSettingsDialog::loadConfiguration()
return;
err:
VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Fail to load configuration."), "",
tr("Fail to load configuration."), "",
QMessageBox::Ok, QMessageBox::Ok, NULL);
QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection);
}
@ -57,7 +57,7 @@ void VSettingsDialog::saveConfiguration()
return;
err:
VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Fail to save configuration. Please try it again."), "",
tr("Fail to save configuration. Please try it again."), "",
QMessageBox::Ok, QMessageBox::Ok, NULL);
}

Binary file not shown.

View File

@ -6,7 +6,7 @@
<message>
<location filename="../dialog/vdirinfodialog.cpp" line="21"/>
<source>Directory &amp;name:</source>
<translation> (&amp;V):</translation>
<translation> (&amp;N):</translation>
</message>
</context>
<context>
@ -16,6 +16,11 @@
<source>Warning</source>
<translation></translation>
</message>
<message>
<location filename="../vdirectory.cpp" line="525"/>
<source>Fail to copy image %1.</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../vdirectory.cpp" line="526"/>
<source>Please check if there already exists a file with the same name and then manually copy it.</source>
@ -105,16 +110,63 @@
<source>Warning</source>
<translation></translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="94"/>
<source>Fail to open notebook %1.</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="137"/>
<source>Fail to open directory %1.</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="298"/>
<source>Create sub-directory under %1.</source>
<translation> %1 </translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="299"/>
<location filename="../vdirectorytree.cpp" line="331"/>
<source>Directory &amp;name:</source>
<translation> (&amp;N):</translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="303"/>
<source>Create Directory</source>
<translation></translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="307"/>
<source>Name already exists under %1. Please choose another name.</source>
<translation> %1 </translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="314"/>
<location filename="../vdirectorytree.cpp" line="346"/>
<source>Fail to create directory %1.</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="330"/>
<source>Create root directory in notebook %1.</source>
<translation> %1 </translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="335"/>
<source>Create Root Directory</source>
<translation></translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="339"/>
<source>Name already exists in notebook %1. Please choose another name.</source>
<translation> %1 </translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="365"/>
<source>Are you sure to delete directory %1?</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="366"/>
<source>This will delete any files under this directory.</source>
@ -125,6 +177,21 @@
<source>Directory Information</source>
<translation></translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="413"/>
<source>Fail to rename directory %1.</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="555"/>
<source>Fail to copy directory %1.</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../vdirectorytree.cpp" line="556"/>
<source>Please check if there alread exists a directory with the same name.</source>
<translation></translation>
</message>
</context>
<context>
<name>VEditTab</name>
@ -133,6 +200,11 @@
<source>Information</source>
<translation></translation>
</message>
<message>
<location filename="../vedittab.cpp" line="209"/>
<source>Note %1 has been modified.</source>
<translation> %1 </translation>
</message>
<message>
<location filename="../vedittab.cpp" line="210"/>
<source>Do you want to save your changes?</source>
@ -150,6 +222,16 @@
<source>Fail to save note.</source>
<translation></translation>
</message>
<message>
<location filename="../vedittab.cpp" line="244"/>
<source>%1 being written has been removed.</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../vedittab.cpp" line="252"/>
<source>Fail to write to disk when saving a note. Please try it again.</source>
<translation></translation>
</message>
</context>
<context>
<name>VEditWindow</name>
@ -279,18 +361,58 @@
<source>Note Information</source>
<translation></translation>
</message>
<message>
<location filename="../vfilelist.cpp" line="176"/>
<source>Create a note in %1.</source>
<translation> %1 </translation>
</message>
<message>
<location filename="../vfilelist.cpp" line="177"/>
<source>Note &amp;name:</source>
<translation> (&amp;N):</translation>
</message>
<message>
<location filename="../vfilelist.cpp" line="180"/>
<source>Create Note</source>
<translation></translation>
</message>
<message>
<location filename="../vfilelist.cpp" line="184"/>
<source>Name already exists. Please choose another name.</source>
<translation></translation>
</message>
<message>
<location filename="../vfilelist.cpp" line="190"/>
<location filename="../vfilelist.cpp" line="247"/>
<location filename="../vfilelist.cpp" line="432"/>
<location filename="../vfilelist.cpp" line="433"/>
<source>Warning</source>
<translation></translation>
</message>
<message>
<location filename="../vfilelist.cpp" line="191"/>
<source>Fail to create note %1.</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../vfilelist.cpp" line="248"/>
<source>Are you sure to delete note %1?</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../vfilelist.cpp" line="249"/>
<source>This may be unrecoverable!</source>
<translation></translation>
</message>
<message>
<location filename="../vfilelist.cpp" line="434"/>
<source>The renaming will change the note type.</source>
<translation></translation>
</message>
<message>
<location filename="../vfilelist.cpp" line="435"/>
<source>You should close the note %1 before continue.</source>
<translation>: %1</translation>
</message>
</context>
<context>
<name>VFindReplaceDialog</name>
@ -720,6 +842,11 @@
<source>Import Notes From File</source>
<translation></translation>
</message>
<message>
<location filename="../vmainwindow.cpp" line="543"/>
<source>Imported notes: %1 succeed, %2 failed.</source>
<translation>: %1 %2 </translation>
</message>
<message>
<location filename="../vmainwindow.cpp" line="629"/>
<source>Use system&apos;s background color configuration for Markdown rendering</source>
@ -961,6 +1088,16 @@ Visit https://github.com/tamlok/vnote.git for more information.</source>
<source>Warning</source>
<translation></translation>
</message>
<message>
<location filename="../vnotebookselector.cpp" line="216"/>
<source>Are you sure to delete notebook %1?</source>
<translation>: %1</translation>
</message>
<message>
<location filename="../vnotebookselector.cpp" line="217"/>
<source>This will delete any files in this notebook (%1).</source>
<translation> (%1)</translation>
</message>
<message>
<location filename="../vnotebookselector.cpp" line="264"/>
<source>Notebook Information</source>
@ -985,5 +1122,15 @@ Visit https://github.com/tamlok/vnote.git for more information.</source>
<source>Warning</source>
<translation></translation>
</message>
<message>
<location filename="../dialog/vsettingsdialog.cpp" line="41"/>
<source>Fail to load configuration.</source>
<translation></translation>
</message>
<message>
<location filename="../dialog/vsettingsdialog.cpp" line="60"/>
<source>Fail to save configuration. Please try it again.</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -522,7 +522,7 @@ VFile *VDirectory::copyFile(VDirectory *p_destDir, const QString &p_destName,
nrPasted++;
} else {
VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Fail to copy image %1.").arg(images[i]),
tr("Fail to copy image %1.").arg(images[i]),
tr("Please check if there already exists a file with the same name and then manually copy it."),
QMessageBox::Ok, QMessageBox::Ok, NULL);
}

View File

@ -91,7 +91,7 @@ void VDirectoryTree::setNotebook(VNotebook *p_notebook)
}
if (!m_notebook->open()) {
VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Fail to open notebook %1.").arg(m_notebook->getName()), "",
tr("Fail to open notebook %1.").arg(m_notebook->getName()), "",
QMessageBox::Ok, QMessageBox::Ok, this);
clear();
return;
@ -134,7 +134,7 @@ void VDirectoryTree::updateDirectoryTreeOne(QTreeWidgetItem *p_parent, int depth
VDirectory *dir = getVDirectory(p_parent);
if (!dir->open()) {
VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Fail to open directory %1.").arg(dir->getName()), "",
tr("Fail to open directory %1.").arg(dir->getName()), "",
QMessageBox::Ok, QMessageBox::Ok, this);
return;
}
@ -295,8 +295,8 @@ void VDirectoryTree::newSubDirectory()
}
VDirectory *curDir = getVDirectory(curItem);
QString info = QString("Create sub-directory under %1.").arg(curDir->getName());
QString text("Directory &name:");
QString info = tr("Create sub-directory under %1.").arg(curDir->getName());
QString text(tr("Directory &name:"));
QString defaultText("new_directory");
do {
@ -304,14 +304,14 @@ void VDirectoryTree::newSubDirectory()
if (dialog.exec() == QDialog::Accepted) {
QString name = dialog.getNameInput();
if (curDir->findSubDirectory(name)) {
info = QString("Name already exists under %1. Please choose another name.").arg(curDir->getName());
info = tr("Name already exists under %1. Please choose another name.").arg(curDir->getName());
defaultText = name;
continue;
}
VDirectory *subDir = curDir->createSubDirectory(name);
if (!subDir) {
VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Fail to create directory %1.").arg(name), "",
tr("Fail to create directory %1.").arg(name), "",
QMessageBox::Ok, QMessageBox::Ok, this);
return;
}
@ -327,8 +327,8 @@ void VDirectoryTree::newRootDirectory()
if (!m_notebook) {
return;
}
QString info = QString("Create root directory in notebook %1.").arg(m_notebook->getName());
QString text("Directory &name:");
QString info = tr("Create root directory in notebook %1.").arg(m_notebook->getName());
QString text(tr("Directory &name:"));
QString defaultText("new_directory");
VDirectory *rootDir = m_notebook->getRootDir();
do {
@ -336,14 +336,14 @@ void VDirectoryTree::newRootDirectory()
if (dialog.exec() == QDialog::Accepted) {
QString name = dialog.getNameInput();
if (rootDir->findSubDirectory(name)) {
info = QString("Name already exists in notebook %1. Please choose another name.").arg(m_notebook->getName());
info = tr("Name already exists in notebook %1. Please choose another name.").arg(m_notebook->getName());
defaultText = name;
continue;
}
VDirectory *subDir = rootDir->createSubDirectory(name);
if (!subDir) {
VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Fail to create directory %1.").arg(name), "",
tr("Fail to create directory %1.").arg(name), "",
QMessageBox::Ok, QMessageBox::Ok, this);
return;
}
@ -362,7 +362,7 @@ void VDirectoryTree::deleteDirectory()
}
VDirectory *curDir = getVDirectory(curItem);
int ret = VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Are you sure to delete directory %1?").arg(curDir->getName()),
tr("Are you sure to delete directory %1?").arg(curDir->getName()),
tr("This will delete any files under this directory."), QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::Ok, this);
if (ret == QMessageBox::Ok) {
@ -410,7 +410,7 @@ void VDirectoryTree::editDirectoryInfo()
}
if (!curDir->rename(name)) {
VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Fail to rename directory %1.").arg(curName), "",
tr("Fail to rename directory %1.").arg(curName), "",
QMessageBox::Ok, QMessageBox::Ok, this);
return;
}
@ -552,8 +552,8 @@ bool VDirectoryTree::copyDirectory(VDirectory *p_destDir, const QString &p_destN
emit directoryUpdated(destDir);
} else {
VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Fail to copy directory %1.").arg(srcName),
QString("Please check if there alread exists a directory with the same name."),
tr("Fail to copy directory %1.").arg(srcName),
tr("Please check if there alread exists a directory with the same name."),
QMessageBox::Ok, QMessageBox::Ok, this);
}

View File

@ -206,7 +206,7 @@ void VEditTab::readFile()
if (m_textEditor->isModified()) {
// Prompt to save the changes
int ret = VUtils::showMessage(QMessageBox::Information, tr("Information"),
QString("Note %1 has been modified.").arg(m_file->getName()),
tr("Note %1 has been modified.").arg(m_file->getName()),
tr("Do you want to save your changes?"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
QMessageBox::Save, this);
@ -241,7 +241,7 @@ bool VEditTab::saveFile()
if (!QFile(filePath).exists()) {
qWarning() << filePath << "being written has been removed";
VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to save note."),
QString("%1 being written has been removed.").arg(filePath),
tr("%1 being written has been removed.").arg(filePath),
QMessageBox::Ok, QMessageBox::Ok, this);
return false;
}
@ -249,7 +249,7 @@ bool VEditTab::saveFile()
ret = m_file->save();
if (!ret) {
VUtils::showMessage(QMessageBox::Warning, tr("Warning"), tr("Fail to save note."),
QString("Fail to write to disk when saving a note. Please try it again."),
tr("Fail to write to disk when saving a note. Please try it again."),
QMessageBox::Ok, QMessageBox::Ok, this);
m_textEditor->setModified(true);
}

View File

@ -173,22 +173,22 @@ void VFileList::newFile()
if (!m_directory) {
return;
}
QString info = QString("Create a note under %1.").arg(m_directory->getName());
QString text("&Note name:");
QString info = tr("Create a note in %1.").arg(m_directory->getName());
QString text(tr("Note &name:"));
QString defaultText("new_note");
do {
VNewFileDialog dialog(QString("Create Note"), info, text, defaultText, this);
VNewFileDialog dialog(tr("Create Note"), info, text, defaultText, this);
if (dialog.exec() == QDialog::Accepted) {
QString name = dialog.getNameInput();
if (m_directory->findFile(name)) {
info = "Name already exists. Please choose another name.";
info = tr("Name already exists. Please choose another name.");
defaultText = name;
continue;
}
VFile *file = m_directory->createFile(name);
if (!file) {
VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Fail to create note %1.").arg(name), "",
tr("Fail to create note %1.").arg(name), "",
QMessageBox::Ok, QMessageBox::Ok, this);
return;
}
@ -245,7 +245,8 @@ void VFileList::deleteFile(VFile *p_file)
VDirectory *dir = p_file->getDirectory();
QString fileName = p_file->getName();
int ret = VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Are you sure to delete note %1?").arg(fileName), tr("This may be unrecoverable!"),
tr("Are you sure to delete note %1?").arg(fileName),
tr("This may be unrecoverable!"),
QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok, this);
if (ret == QMessageBox::Ok) {
editArea->closeFile(p_file, true);
@ -430,8 +431,8 @@ bool VFileList::copyFile(VDirectory *p_destDir, const QString &p_destName, VFile
if (docType != newDocType) {
if (editArea->isFileOpened(p_file)) {
int ret = VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("The renaming will change the note type."),
QString("You should close the note %1 before continue.").arg(p_file->getName()),
tr("The renaming will change the note type."),
tr("You should close the note %1 before continue.").arg(p_file->getName()),
QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok, this);
if (QMessageBox::Ok == ret) {
if (!editArea->closeFile(p_file, false)) {

View File

@ -540,7 +540,7 @@ void VMainWindow::importNoteFromFile()
}
}
QMessageBox msgBox(QMessageBox::Information, tr("Import Notes From File"),
QString("Imported notes: %1 succeed, %2 failed.")
tr("Imported notes: %1 succeed, %2 failed.")
.arg(files.size() - failedFiles.size()).arg(failedFiles.size()),
QMessageBox::Ok, this);
if (!failedFiles.isEmpty()) {

View File

@ -213,8 +213,8 @@ void VNotebookSelector::deleteNotebook()
QString curPath = notebook->getPath();
int ret = VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
QString("Are you sure to delete notebook %1?").arg(curName),
QString("This will delete any files in this notebook (%1).").arg(curPath),
tr("Are you sure to delete notebook %1?").arg(curName),
tr("This will delete any files in this notebook (%1).").arg(curPath),
QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok, this);
if (ret == QMessageBox::Ok) {
m_editArea->closeFile(notebook, true);