From: dbv Date: Mon, 5 Dec 2016 13:19:44 +0000 (+0300) Subject: Issue #1005: To improve user-friendship of error-messages for features and attributes X-Git-Tag: V_2.6.0~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cb7a2859201a88a209e27e272053a0372164f547;p=modules%2Fshaper.git Issue #1005: To improve user-friendship of error-messages for features and attributes Improved translation mechanism. --- diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index 5427e7dd3..036631731 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -137,7 +138,8 @@ bool Config_FeatureReader::processChildren(xmlNodePtr theNode) void Config_FeatureReader::fillFeature(xmlNodePtr theFeatureNode, const std::shared_ptr& outFeatureMessage) { - outFeatureMessage->setId(getProperty(theFeatureNode, _ID)); + std::string anId = getProperty(theFeatureNode, _ID); + outFeatureMessage->setId(anId); outFeatureMessage->setPluginLibrary(myLibraryName); outFeatureMessage->setNestedFeatures(getProperty(theFeatureNode, FEATURE_NESTED)); outFeatureMessage->setActionsWhenNested(getNormalizedProperty(theFeatureNode, @@ -151,8 +153,10 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theFeatureNode, return; } - outFeatureMessage->setText(getProperty(theFeatureNode, FEATURE_TEXT)); - outFeatureMessage->setTooltip(getProperty(theFeatureNode, FEATURE_TOOLTIP)); + std::string aText = Config_Translator::translate(anId, getProperty(theFeatureNode, FEATURE_TEXT)); + outFeatureMessage->setText(aText); + std::string aToolTip = Config_Translator::translate(anId, getProperty(theFeatureNode, FEATURE_TOOLTIP)); + outFeatureMessage->setTooltip(aToolTip); outFeatureMessage->setIcon(getProperty(theFeatureNode, FEATURE_ICON)); outFeatureMessage->setKeysequence(getProperty(theFeatureNode, FEATURE_KEYSEQUENCE)); outFeatureMessage->setGroupId(restoreAttribute(NODE_GROUP, _ID)); diff --git a/src/Config/Config_Translator.h b/src/Config/Config_Translator.h index 4fbfcb5b9..89bf4d1e1 100644 --- a/src/Config/Config_Translator.h +++ b/src/Config/Config_Translator.h @@ -15,7 +15,7 @@ /// The definition provides collection and writing of missed translations -//#define MISSED_TRANSLATION +#define MISSED_TRANSLATION /** * \class Config_Translator diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 637f3b578..87ffbbd49 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -80,6 +80,7 @@ SET(XML_RESOURCES SET(TEXT_RESOURCES FeaturesPlugin_msg_en.ts + FeaturesPlugin_msg_ru.ts ) SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES}) diff --git a/src/FeaturesPlugin/FeaturesPlugin_msg_en.ts b/src/FeaturesPlugin/FeaturesPlugin_msg_en.ts index cb3524341..1e7fab54d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_msg_en.ts +++ b/src/FeaturesPlugin/FeaturesPlugin_msg_en.ts @@ -2636,150 +2636,143 @@ - Boolean:GeomValidators_BooleanArguments + Boolean - Not enough arguments - Not enough arguments for the operation + Boolean + Boolean - - - Boolean:GeomValidators_BooleanArguments - Wrong number of arguments (expected 3). - Wrong number of validator "GeomValidators_BooleanArguments" arguments (expected 3). + Boolean operations with objects + Boolean operations with objects - Boolean:Model_FeatureValidator + Boolean:bool_type - Attribute "bool_type" is not initialized. - + Operation type + Operation type - - - Boolean:Model_FeatureValidator - Attribute "main_objects" is not initialized. - Objects not selected. + Type of boolean operation + Type of boolean operation - - - Boolean:Model_FeatureValidator - Attribute "tool_objects" is not initialized. - Tools not selected. + Cut + Cut + + + Fuse + Fuse + + + Common + Common + + + Fill + Fill + + + Smash + Smash - Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection + Boolean:main_objects - Error: This validator can only work with selection list attributes in \"Boolean\" feature. - + Main objects + Main objects + + + Select objects + Select objects Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection Error: Empty attribute selection. - Objects not selected. + Select objects. - - - Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection Error: Empty selection context. - + Selected object invalid. - - - Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection Error: Result construction not allowed for selection. Result construction not allowed for selection. - - - Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection Error: Empty shape. - + Selected object invalid. - - - Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection Error: Local selection not allowed. Local selection not allowed. - - - Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection Error: Selected shape has the wrong type. Selected shape has the wrong type. - Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection + Boolean:tool_objects - Error: Selected shape has the wrong type. - Selected shape has the wrong type. + Tool objects + Tool objects - - - Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection - Error: This validator can only work with selection list attributes in \"Boolean\" feature. - + Select tools + Select tools Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection Error: Empty attribute selection. - Tools not selected. + Select tools. - - - Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection Error: Empty selection context. - + Selected tool invalid. - - - Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection Error: Result construction not allowed for selection. Result construction not allowed for selection. - - - Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection Error: Empty shape. - + Selected tool invalid. - - - Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection Error: Local selection not allowed. Local selection not allowed. - - - Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection Error: Selected shape has the wrong type. Selected shape has the wrong type. - Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection + Boolean:GeomValidators_BooleanArguments - Error: Selected shape has the wrong type. - Selected shape has the wrong type. + Not enough arguments + Not enough arguments. + + + + Boolean:Model_FeatureValidator + + Attribute "bool_type" is not initialized. + Select operation type. + + + Attribute "main_objects" is not initialized. + Select objects. + + + Attribute "tool_objects" is not initialized. + Select tools. diff --git a/src/FeaturesPlugin/FeaturesPlugin_msg_ru.ts b/src/FeaturesPlugin/FeaturesPlugin_msg_ru.ts new file mode 100644 index 000000000..690108637 --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_msg_ru.ts @@ -0,0 +1,144 @@ + + + + + Boolean + + Boolean + Булевы операции + + + Perform boolean operations with objects + Производит булевы операции с объектами + + + + Boolean:bool_type + + Operation type + Тип операции + + + Type of boolean operation + Тип булевой операции + + + Cut + Вырезание + + + Fuse + Объединение + + + Common + Пересечение + + + Fill + Заполнение + + + Smash + Вдавливание + + + + Boolean:main_objects + + Main objects + Основные объекты + + + Select objects + Выберите основные объекты + + + + Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection + + Error: Empty attribute selection. + Выберите основные объекты. + + + Error: Empty selection context. + Выбранные основные объекты невалидны. + + + Error: Result construction not allowed for selection. + Нельзя селектировать конструкции. + + + Error: Empty shape. + Выбранные основные объекты невалидны. + + + Error: Local selection not allowed. + Локальная селекция запрещена. + + + Error: Selected shape has the wrong type. + Выбраныне основные объекты имеют недопустимый тип. + + + + Boolean:tool_objects + + Tool objects + Вспомогательные объекты + + + Select tools + Выберите вспомогательные объекты + + + + Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection + + Error: Empty attribute selection. + Выберите вспомогательные объекты. + + + Error: Empty selection context. + Выбранные вспомогательные объекты невалидны. + + + Error: Result construction not allowed for selection. + Нельзя селектировать конструкции. + + + Error: Empty shape. + Выбранные вспомогательные объекты невалидны. + + + Error: Local selection not allowed. + Локальная селекция запрещена. + + + Error: Selected shape has the wrong type. + Выбраныне вспомогательные объекты имеют недопустимый тип. + + + + Boolean:GeomValidators_BooleanArguments + + Not enough arguments + Недостаточно объектов для операции. + + + + Boolean:Model_FeatureValidator + + Attribute "bool_type" is not initialized. + Выберите тип операции. + + + Attribute "main_objects" is not initialized. + Выберите основные объекты. + + + Attribute "tool_objects" is not initialized. + Выберите вспомогательные объекты. + + + diff --git a/src/FeaturesPlugin/boolean_widget.xml b/src/FeaturesPlugin/boolean_widget.xml index 262c1c97a..4b37febe8 100644 --- a/src/FeaturesPlugin/boolean_widget.xml +++ b/src/FeaturesPlugin/boolean_widget.xml @@ -14,7 +14,7 @@ @@ -24,7 +24,7 @@ diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index b7f98d6ae..96a88f4df 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -30,7 +30,7 @@ - diff --git a/src/ModuleBase/ModuleBase_ActionInfo.cpp b/src/ModuleBase/ModuleBase_ActionInfo.cpp index bf1c5a1da..0d4a3a974 100644 --- a/src/ModuleBase/ModuleBase_ActionInfo.cpp +++ b/src/ModuleBase/ModuleBase_ActionInfo.cpp @@ -58,8 +58,8 @@ void ModuleBase_ActionInfo::initFrom(std::shared_ptr theM if (!iconFile.isEmpty()) { icon = ModuleBase_IconFactory::loadIcon(iconFile); } - text = ModuleBase_Tools::translate(theMessage->id(), theMessage->text()); - toolTip = ModuleBase_Tools::translate(theMessage->id(), theMessage->tooltip()); + text = QString::fromUtf8(theMessage->text().c_str()); + toolTip = QString::fromUtf8(theMessage->tooltip().c_str()); QString aShortcutStr = QString::fromStdString(theMessage->keysequence()); if (!aShortcutStr.isEmpty()) { shortcut = QKeySequence(aShortcutStr); diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index 7a90b5f26..49ade2db4 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -105,7 +105,7 @@ QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature) { // Error already translated. std::string aMsg = ModelAPI_Tools::getFeatureError(theFeature); - return aMsg.c_str(); + return QString::fromUtf8(aMsg.c_str()); } void ModuleBase_IModule::grantedOperationIds(ModuleBase_Operation* theOperation, diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 86265430b..47bfd5355 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -137,10 +137,10 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) // Has to be defined first in order to get errors and messages from other components myEventsListener = new XGUI_WorkshopListener(aWorkshop); + SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr(); #ifndef HAVE_SALOME myMainWindow = new AppElements_MainWindow(); - SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr(); bool aCloc = aResMgr->booleanValue("language", "locale", true); if (aCloc) QLocale::setDefault( QLocale::c() ); @@ -151,11 +151,20 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) QDir aDir(aPath); // Load translations - QStringList aFilters; - aFilters << "*_en.ts"; - QStringList aTsFiles = aDir.entryList(aFilters, QDir::Files); - foreach(QString aFileName, aTsFiles) { - Config_Translator::load(aFileName.toStdString()); + QStringList aLangs; + aLangs << "*_en.ts"; // load by default eng translations + QString aCurrLang = aResMgr->stringValue("language", "language", "en"); + if(aCurrLang != "en") { + aLangs << "*_" + aCurrLang + ".ts"; // then replace with translated files + } + + foreach(QString aLang, aLangs) { + QStringList aFilters; + aFilters << aLang; + QStringList aTsFiles = aDir.entryList(aFilters, QDir::Files); + foreach(QString aFileName, aTsFiles) { + Config_Translator::load(aFileName.toStdString()); + } } myDataModelXMLReader = new Config_DataModelReader();