[TD]translate line names at time of use
This commit is contained in:
@@ -22,11 +22,36 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include "Preferences.h"
|
||||
|
||||
#include "LineNameEnum.h"
|
||||
|
||||
|
||||
namespace TechDraw {
|
||||
|
||||
// these strings have to be kept in order according to Preferences::lineStandard()
|
||||
std::vector<std::string> LineName::ContextStrings{
|
||||
"ANSILineTypeEnum",
|
||||
"ASMELineTypeEnum",
|
||||
"ISOLineTypeEnum" };
|
||||
|
||||
std::string LineName::translationContext(size_t iStandard)
|
||||
{
|
||||
if (iStandard < ContextStrings.size() &&
|
||||
iStandard > 0) {
|
||||
return ContextStrings[iStandard];
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
std::string LineName::currentTranslationContext()
|
||||
{
|
||||
return translationContext(Preferences::lineStandard());
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! line numbers begin at 1, not 0
|
||||
|
||||
const int ISOLineName::ISOLineNameCount = 15;
|
||||
|
||||
@@ -33,8 +33,18 @@
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
|
||||
|
||||
//! common definitions for line numbers, names and lineicon names
|
||||
|
||||
class TechDrawExport LineName {
|
||||
public:
|
||||
static std::string translationContext(size_t iStandard);
|
||||
static std::string currentTranslationContext();
|
||||
|
||||
static std::vector<std::string> ContextStrings;
|
||||
};
|
||||
|
||||
class TechDrawExport ISOLineName {
|
||||
Q_DECLARE_TR_FUNCTIONS(TechDraw::ISOLineName)
|
||||
|
||||
|
||||
@@ -180,9 +180,10 @@ void DrawGuiUtil::loadLineStyleChoices(QComboBox* combo, LineGenerator* generato
|
||||
choices = LineGenerator::getLineDescriptions();
|
||||
}
|
||||
|
||||
auto translationContext = LineName::currentTranslationContext();
|
||||
int itemNumber {0};
|
||||
for (auto& entry : choices) {
|
||||
QString qentry = Base::Tools::fromStdString(entry);
|
||||
QString qentry = QCoreApplication::translate(translationContext.c_str(), entry.c_str());
|
||||
combo->addItem(qentry);
|
||||
if (generator) {
|
||||
combo->setItemIcon(itemNumber, iconForLine(itemNumber + 1, generator));
|
||||
|
||||
Reference in New Issue
Block a user