Improved translation mechanism.
#include <Config_FeatureMessage.h>
#include <Config_AttributeMessage.h>
#include <Config_FeatureReader.h>
+#include <Config_Translator.h>
#include <Events_Message.h>
#include <Events_Loop.h>
void Config_FeatureReader::fillFeature(xmlNodePtr theFeatureNode,
const std::shared_ptr<Config_FeatureMessage>& 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,
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));
/// The definition provides collection and writing of missed translations
-//#define MISSED_TRANSLATION
+#define MISSED_TRANSLATION
/**
* \class Config_Translator
SET(TEXT_RESOURCES
FeaturesPlugin_msg_en.ts
+ FeaturesPlugin_msg_ru.ts
)
SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES})
</message>
</context>
<context>
- <name>Boolean:GeomValidators_BooleanArguments</name>
+ <name>Boolean</name>
<message>
- <source>Not enough arguments</source>
- <translation>Not enough arguments for the operation</translation>
+ <source>Boolean</source>
+ <translation>Boolean</translation>
</message>
- </context>
- <context>
- <name>Boolean:GeomValidators_BooleanArguments</name>
<message>
- <source>Wrong number of arguments (expected 3).</source>
- <translation>Wrong number of validator "GeomValidators_BooleanArguments" arguments (expected 3).</translation>
+ <source>Boolean operations with objects</source>
+ <translation>Boolean operations with objects</translation>
</message>
</context>
<context>
- <name>Boolean:Model_FeatureValidator</name>
+ <name>Boolean:bool_type</name>
<message>
- <source>Attribute "bool_type" is not initialized.</source>
- <translation></translation>
+ <source>Operation type</source>
+ <translation>Operation type</translation>
</message>
- </context>
- <context>
- <name>Boolean:Model_FeatureValidator</name>
<message>
- <source>Attribute "main_objects" is not initialized.</source>
- <translation>Objects not selected.</translation>
+ <source>Type of boolean operation</source>
+ <translation>Type of boolean operation</translation>
</message>
- </context>
- <context>
- <name>Boolean:Model_FeatureValidator</name>
<message>
- <source>Attribute "tool_objects" is not initialized.</source>
- <translation>Tools not selected.</translation>
+ <source>Cut</source>
+ <translation>Cut</translation>
+ </message>
+ <message>
+ <source>Fuse</source>
+ <translation>Fuse</translation>
+ </message>
+ <message>
+ <source>Common</source>
+ <translation>Common</translation>
+ </message>
+ <message>
+ <source>Fill</source>
+ <translation>Fill</translation>
+ </message>
+ <message>
+ <source>Smash</source>
+ <translation>Smash</translation>
</message>
</context>
<context>
- <name>Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
+ <name>Boolean:main_objects</name>
<message>
- <source>Error: This validator can only work with selection list attributes in \"Boolean\" feature.</source>
- <translation></translation>
+ <source>Main objects</source>
+ <translation>Main objects</translation>
+ </message>
+ <message>
+ <source>Select objects</source>
+ <translation>Select objects</translation>
</message>
</context>
<context>
<name>Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
<source>Error: Empty attribute selection.</source>
- <translation>Objects not selected.</translation>
+ <translation>Select objects.</translation>
</message>
- </context>
- <context>
- <name>Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
<source>Error: Empty selection context.</source>
- <translation></translation>
+ <translation>Selected object invalid.</translation>
</message>
- </context>
- <context>
- <name>Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
<source>Error: Result construction not allowed for selection.</source>
<translation>Result construction not allowed for selection.</translation>
</message>
- </context>
- <context>
- <name>Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
<source>Error: Empty shape.</source>
- <translation></translation>
+ <translation>Selected object invalid.</translation>
</message>
- </context>
- <context>
- <name>Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
<source>Error: Local selection not allowed.</source>
<translation>Local selection not allowed.</translation>
</message>
- </context>
- <context>
- <name>Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
<source>Error: Selected shape has the wrong type.</source>
<translation>Selected shape has the wrong type.</translation>
</message>
</context>
<context>
- <name>Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
+ <name>Boolean:tool_objects</name>
<message>
- <source>Error: Selected shape has the wrong type.</source>
- <translation>Selected shape has the wrong type.</translation>
+ <source>Tool objects</source>
+ <translation>Tool objects</translation>
</message>
- </context>
- <context>
- <name>Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
- <source>Error: This validator can only work with selection list attributes in \"Boolean\" feature.</source>
- <translation></translation>
+ <source>Select tools</source>
+ <translation>Select tools</translation>
</message>
</context>
<context>
<name>Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
<source>Error: Empty attribute selection.</source>
- <translation>Tools not selected.</translation>
+ <translation>Select tools.</translation>
</message>
- </context>
- <context>
- <name>Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
<source>Error: Empty selection context.</source>
- <translation></translation>
+ <translation>Selected tool invalid.</translation>
</message>
- </context>
- <context>
- <name>Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
<source>Error: Result construction not allowed for selection.</source>
<translation>Result construction not allowed for selection.</translation>
</message>
- </context>
- <context>
- <name>Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
<source>Error: Empty shape.</source>
- <translation></translation>
+ <translation>Selected tool invalid.</translation>
</message>
- </context>
- <context>
- <name>Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
<source>Error: Local selection not allowed.</source>
<translation>Local selection not allowed.</translation>
</message>
- </context>
- <context>
- <name>Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
<message>
<source>Error: Selected shape has the wrong type.</source>
<translation>Selected shape has the wrong type.</translation>
</message>
</context>
<context>
- <name>Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
+ <name>Boolean:GeomValidators_BooleanArguments</name>
<message>
- <source>Error: Selected shape has the wrong type.</source>
- <translation>Selected shape has the wrong type.</translation>
+ <source>Not enough arguments</source>
+ <translation>Not enough arguments.</translation>
+ </message>
+ </context>
+ <context>
+ <name>Boolean:Model_FeatureValidator</name>
+ <message>
+ <source>Attribute "bool_type" is not initialized.</source>
+ <translation>Select operation type.</translation>
+ </message>
+ <message>
+ <source>Attribute "main_objects" is not initialized.</source>
+ <translation>Select objects.</translation>
+ </message>
+ <message>
+ <source>Attribute "tool_objects" is not initialized.</source>
+ <translation>Select tools.</translation>
</message>
</context>
<context>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="ru_RU">
+ <context>
+ <name>Boolean</name>
+ <message>
+ <source>Boolean</source>
+ <translation>Булевы операции</translation>
+ </message>
+ <message>
+ <source>Perform boolean operations with objects</source>
+ <translation>Производит булевы операции с объектами</translation>
+ </message>
+ </context>
+ <context>
+ <name>Boolean:bool_type</name>
+ <message>
+ <source>Operation type</source>
+ <translation>Тип операции</translation>
+ </message>
+ <message>
+ <source>Type of boolean operation</source>
+ <translation>Тип булевой операции</translation>
+ </message>
+ <message>
+ <source>Cut</source>
+ <translation>Вырезание</translation>
+ </message>
+ <message>
+ <source>Fuse</source>
+ <translation>Объединение</translation>
+ </message>
+ <message>
+ <source>Common</source>
+ <translation>Пересечение</translation>
+ </message>
+ <message>
+ <source>Fill</source>
+ <translation>Заполнение</translation>
+ </message>
+ <message>
+ <source>Smash</source>
+ <translation>Вдавливание</translation>
+ </message>
+ </context>
+ <context>
+ <name>Boolean:main_objects</name>
+ <message>
+ <source>Main objects</source>
+ <translation>Основные объекты</translation>
+ </message>
+ <message>
+ <source>Select objects</source>
+ <translation>Выберите основные объекты</translation>
+ </message>
+ </context>
+ <context>
+ <name>Boolean:main_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
+ <message>
+ <source>Error: Empty attribute selection.</source>
+ <translation>Выберите основные объекты.</translation>
+ </message>
+ <message>
+ <source>Error: Empty selection context.</source>
+ <translation>Выбранные основные объекты невалидны.</translation>
+ </message>
+ <message>
+ <source>Error: Result construction not allowed for selection.</source>
+ <translation>Нельзя селектировать конструкции.</translation>
+ </message>
+ <message>
+ <source>Error: Empty shape.</source>
+ <translation>Выбранные основные объекты невалидны.</translation>
+ </message>
+ <message>
+ <source>Error: Local selection not allowed.</source>
+ <translation>Локальная селекция запрещена.</translation>
+ </message>
+ <message>
+ <source>Error: Selected shape has the wrong type.</source>
+ <translation>Выбраныне основные объекты имеют недопустимый тип.</translation>
+ </message>
+ </context>
+ <context>
+ <name>Boolean:tool_objects</name>
+ <message>
+ <source>Tool objects</source>
+ <translation>Вспомогательные объекты</translation>
+ </message>
+ <message>
+ <source>Select tools</source>
+ <translation>Выберите вспомогательные объекты</translation>
+ </message>
+ </context>
+ <context>
+ <name>Boolean:tool_objects:FeaturesPlugin_ValidatorBooleanSelection</name>
+ <message>
+ <source>Error: Empty attribute selection.</source>
+ <translation>Выберите вспомогательные объекты.</translation>
+ </message>
+ <message>
+ <source>Error: Empty selection context.</source>
+ <translation>Выбранные вспомогательные объекты невалидны.</translation>
+ </message>
+ <message>
+ <source>Error: Result construction not allowed for selection.</source>
+ <translation>Нельзя селектировать конструкции.</translation>
+ </message>
+ <message>
+ <source>Error: Empty shape.</source>
+ <translation>Выбранные вспомогательные объекты невалидны.</translation>
+ </message>
+ <message>
+ <source>Error: Local selection not allowed.</source>
+ <translation>Локальная селекция запрещена.</translation>
+ </message>
+ <message>
+ <source>Error: Selected shape has the wrong type.</source>
+ <translation>Выбраныне вспомогательные объекты имеют недопустимый тип.</translation>
+ </message>
+ </context>
+ <context>
+ <name>Boolean:GeomValidators_BooleanArguments</name>
+ <message>
+ <source>Not enough arguments</source>
+ <translation>Недостаточно объектов для операции.</translation>
+ </message>
+ </context>
+ <context>
+ <name>Boolean:Model_FeatureValidator</name>
+ <message>
+ <source>Attribute "bool_type" is not initialized.</source>
+ <translation>Выберите тип операции.</translation>
+ </message>
+ <message>
+ <source>Attribute "main_objects" is not initialized.</source>
+ <translation>Выберите основные объекты.</translation>
+ </message>
+ <message>
+ <source>Attribute "tool_objects" is not initialized.</source>
+ <translation>Выберите вспомогательные объекты.</translation>
+ </message>
+ </context>
+</TS>
<multi_selector id="main_objects"
label="Main objects"
icon=""
- tooltip="Select solid objects"
+ tooltip="Select objects"
type_choice="solids compsolids edges faces"
use_choice="false"
concealment="true">
<multi_selector id="tool_objects"
label="Tool objects"
icon=""
- tooltip="Select a tool solid"
+ tooltip="Select tools"
type_choice="solids compsolids edges faces"
use_choice="false"
concealment="true" >
</feature>
</group>
<group id="Boolean">
- <feature id="Boolean" title="Boolean" tooltip="Perform boolean operations with solids" icon="icons/Features/cut.png"
+ <feature id="Boolean" title="Boolean" tooltip="Perform boolean operations with objects" icon="icons/Features/cut.png"
auto_preview="false">
<source path="boolean_widget.xml"/>
</feature>
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);
{
// 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,
// 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() );
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();