1 /** 2 * UGENE - Integrated Bioinformatics Tools. 3 * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru> 4 * http://ugene.net 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 22 #ifndef _U2_L10N_H_ 23 #define _U2_L10N_H_ 24 25 #include <QColor> 26 27 #include <U2Core/GUrl.h> 28 #include <U2Core/global.h> 29 30 namespace U2 { 31 32 class U2CORE_EXPORT L10N : public QObject { 33 Q_OBJECT 34 public: 35 // general purpose messages errorTitle()36 static QString errorTitle() { 37 return tr("Error!"); 38 } warningTitle()39 static QString warningTitle() { 40 return tr("Warning!"); 41 } badArgument(const QString & name)42 static QString badArgument(const QString &name) { 43 return tr("Internal error, bad argument: %1").arg(name); 44 } outOfMemory()45 static QString outOfMemory() { 46 return tr("Out of memory!"); 47 } internalError()48 static QString internalError() { 49 return tr("Internal error!"); 50 } internalError(const QString & message)51 static QString internalError(const QString &message) { 52 return internalError() + " " + message; 53 } nullPointerError(const QString & objectName)54 static QString nullPointerError(const QString &objectName) { 55 return tr("Internal error! The object unexpectedly does not exist: ") + objectName; 56 } 57 58 // messages to work with files errorOpeningFileRead(const GUrl & url)59 static QString errorOpeningFileRead(const GUrl &url) { 60 return tr("Error opening file for reading: '%1'").arg(url.getURLString()); 61 } errorOpeningFileWrite(const GUrl & url)62 static QString errorOpeningFileWrite(const GUrl &url) { 63 return tr("Error opening file for writing: '%1'").arg(url.getURLString()); 64 } errorWritingFile(const GUrl & url)65 static QString errorWritingFile(const GUrl &url) { 66 return tr("Write error: '%1'").arg(url.getURLString()); 67 } errorReadingFile(const GUrl & url)68 static QString errorReadingFile(const GUrl &url) { 69 return tr("Read error: %1").arg(url.getURLString()); 70 } errorFileTooLarge(const GUrl & url)71 static QString errorFileTooLarge(const GUrl &url) { 72 return tr("File is too large: '%1'").arg(url.getURLString()); 73 } errorFileNotFound(const GUrl & url)74 static QString errorFileNotFound(const GUrl &url) { 75 return tr("File not found: '%1'").arg(url.getURLString()); 76 } errorIsNotAFile(const GUrl & url)77 static QString errorIsNotAFile(const GUrl &url) { 78 return tr("'%1' is not a file").arg(url.getURLString()); 79 } errorDirNotFound(const GUrl & url)80 static QString errorDirNotFound(const GUrl &url) { 81 return tr("Folder not found: '%1'").arg(url.getURLString()); 82 } errorOpeningDir(const GUrl & url)83 static QString errorOpeningDir(const GUrl &url) { 84 return tr("Error opening folder: '%1'").arg(url.getURLString()); 85 } errorIsNotADir(const GUrl & url)86 static QString errorIsNotADir(const GUrl &url) { 87 return tr("'%1' is not a folder").arg(url.getURLString()); 88 } warningCharactersCodePage(const QString & url)89 static QString warningCharactersCodePage(const QString &url) { 90 return tr("Avoid characters in the '%1' parameter that do not correspond to the operating system locale settings.").arg(url); 91 } 92 93 // messages to work with a shared database errorWrongDbObjUrlFormat(const QString & url)94 static QString errorWrongDbObjUrlFormat(const QString &url) { 95 return tr("'%1' does not match database object URL format").arg(url); 96 } errorWrongDbFolderUrlFormat(const QString & url)97 static QString errorWrongDbFolderUrlFormat(const QString &url) { 98 return tr("'%1' does not match database folder URL format").arg(url); 99 } errorDbInacsessible(const QString & url)100 static QString errorDbInacsessible(const QString &url) { 101 return tr("Unable to connect to the database '%1'. Check your connection settings in File -> Connect to shared database").arg(url); 102 } errorDbObjectInaccessible(const QString & url,const QString & name)103 static QString errorDbObjectInaccessible(const QString &url, const QString &name) { 104 return tr("Unable to find the object '%1' in the database '%2'").arg(name).arg(url); 105 } errorDbFolderInacsessible(const QString & url,const QString & path)106 static QString errorDbFolderInacsessible(const QString &url, const QString &path) { 107 return tr("Unable to find the folder '%1' with the specified path in the database '%2'").arg(path).arg(url); 108 } errorDbWritePermissons(const QString & url)109 static QString errorDbWritePermissons(const QString &url) { 110 return tr("You do not have write permissions to the database '%1'").arg(url); 111 } 112 notValidFileFormat(const QString & type,const GUrl & url)113 static QString notValidFileFormat(const QString &type, const GUrl &url) { 114 return tr("Invalid file format. Expected file format: %1, File: %2").arg(type).arg(url.getURLString()); 115 } notSupportedFileFormat(const GUrl & url)116 static QString notSupportedFileFormat(const GUrl &url) { 117 return tr("Invalid file format! File: %1").arg(url.getURLString()); 118 } 119 120 // working with qt plugins: images, scripts, styles errorImageSave(const QString & file,const QString & format)121 static QString errorImageSave(const QString &file, const QString &format) { 122 return tr("Can't save image to file %1, format %2").arg(file).arg(format); 123 } errorDocumentNotFound(const GUrl & url)124 static QString errorDocumentNotFound(const GUrl &url) { 125 return tr("Document not found: %1").arg(url.getURLString()); 126 } 127 errorObjectNotFound(const QString & objectName)128 static QString errorObjectNotFound(const QString &objectName) { 129 return tr("Object not found: %1").arg(objectName); 130 } 131 errorObjectIsReadOnly(const QString & objectName)132 static QString errorObjectIsReadOnly(const QString &objectName) { 133 return tr("Object is read only: %1").arg(objectName); 134 } 135 suffixBp()136 static QString suffixBp() { 137 return tr(" bp"); 138 } 139 defaultStr()140 static QString defaultStr() { 141 return "default"; 142 } // It is used in WD, do not translate this without testing 143 directStrandStr()144 static QString directStrandStr() { 145 return tr("Direct"); 146 } complementStrandStr()147 static QString complementStrandStr() { 148 return tr("Reverse-complementary"); 149 } 150 required()151 static QString required() { 152 return tr("Required"); 153 } 154 155 /** 156 * Returns active language code: 'en', 'ru', 'tr'. 157 * The string 'ugene-active-translation-language-code' must be correctly translated in the .ts file. 158 * If the string is not translated, 'en' is returned as the default. 159 */ getActiveLanguageCode()160 static QString getActiveLanguageCode() { 161 QString code = tr("ugene-active-translation-language-code"); 162 return code.isEmpty() || code == "ugene-active-translation-language-code" ? "en" : code; 163 } 164 }; 165 166 } // namespace U2 167 168 #endif 169