Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Mark strings as translatable where applicable #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/Editor/CEditorApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bool CEditorApplication::OpenProject(const QString& rkProjPath)
// Load new project
TString Path = TO_TSTRING(rkProjPath);

CProgressDialog Dialog("Opening " + TO_QSTRING(Path.GetFileName()), true, true, mpWorldEditor);
CProgressDialog Dialog(tr("Opening %1").arg(TO_QSTRING(Path.GetFileName())), true, true, mpWorldEditor);
Dialog.DisallowCanceling();
// Gross, but necessary until QtConcurrent supports move only types.
QFuture<CGameProject*> Future = QtConcurrent::run([](const auto& path, auto* dialog) { return CGameProject::LoadProject(path, dialog).release(); }, Path, &Dialog);
Expand All @@ -106,7 +106,7 @@ bool CEditorApplication::OpenProject(const QString& rkProjPath)
}
else
{
UICommon::ErrorMsg(mpWorldEditor, "Failed to open project!");
UICommon::ErrorMsg(mpWorldEditor, tr("Failed to open project!"));
return false;
}
}
Expand All @@ -130,7 +130,7 @@ void CEditorApplication::EditResource(CResourceEntry *pEntry)

if (!pRes)
{
UICommon::ErrorMsg(mpWorldEditor, "Failed to load resource!");
UICommon::ErrorMsg(mpWorldEditor, tr("Failed to load resource!"));
return;
}

Expand Down Expand Up @@ -197,7 +197,9 @@ void CEditorApplication::EditResource(CResourceEntry *pEntry)
mEditingMap[pEntry] = pEd;
}
else if (pEntry->ResourceType() != EResourceType::Area)
UICommon::InfoMsg(mpWorldEditor, "Unsupported Resource", "This resource type is currently unsupported for editing.");
{
UICommon::InfoMsg(mpWorldEditor, tr("Unsupported Resource"), tr("This resource type is currently unsupported for editing."));
}
}
}

Expand Down Expand Up @@ -231,7 +233,7 @@ bool CEditorApplication::CookPackageList(QList<CPackage*> PackageList)
{
if (!PackageList.isEmpty())
{
CProgressDialog Dialog("Cooking package" + QString(PackageList.size() > 1 ? "s" : ""), false, true, mpWorldEditor);
CProgressDialog Dialog(tr("Cooking package%1").arg(QString(PackageList.size() > 1 ? "s" : "")), false, true, mpWorldEditor);

QFuture<void> Future = QtConcurrent::run([&]()
{
Expand Down Expand Up @@ -280,7 +282,7 @@ bool CEditorApplication::RebuildResourceDatabase()
emit ActiveProjectChanged(nullptr);

// Rebuild
CProgressDialog Dialog("Rebuilding resource database", true, false, mpWorldEditor);
CProgressDialog Dialog(tr("Rebuilding resource database"), true, false, mpWorldEditor);
Dialog.SetOneShotTask("Rebuilding resource database");
Dialog.DisallowCanceling();

Expand All @@ -293,7 +295,7 @@ bool CEditorApplication::RebuildResourceDatabase()
mpActiveProject->TweakManager()->LoadTweaks();
emit ActiveProjectChanged(mpActiveProject.get());

UICommon::InfoMsg(mpWorldEditor, "Success", "Resource database rebuilt successfully!");
UICommon::InfoMsg(mpWorldEditor, tr("Success"), tr("Resource database rebuilt successfully!"));
return true;
}

Expand Down
10 changes: 5 additions & 5 deletions src/Editor/CErrorLogDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ bool CErrorLogDialog::GatherErrors()
QString Error = TO_QSTRING(*it);
QString LineColor;

if (Error.startsWith("ERROR: "))
if (Error.startsWith(QStringLiteral("ERROR: ")))
LineColor = "#ff0000";
else if (Error.startsWith("Warning: "))
else if (Error.startsWith(QStringLiteral("Warning: ")))
LineColor = "#ff8000";

QString FullLine = Error;

if (!LineColor.isEmpty())
{
FullLine.prepend(QString("<font color=\"%1\">").arg(LineColor));
FullLine.append("</font>");
FullLine.prepend(QStringLiteral("<font color=\"%1\">").arg(LineColor));
FullLine.append(QStringLiteral("</font>"));
}
FullLine.append("<br />");
FullLine.append(QStringLiteral("<br />"));

DialogString += FullLine;
}
Expand Down
60 changes: 31 additions & 29 deletions src/Editor/CExportGameDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CExportGameDialog::CExportGameDialog(const QString& rkIsoPath, const QString& rk
InitUI(rkExportDir);

TString IsoName = TO_TSTRING(rkIsoPath).GetFileName();
setWindowTitle(QString("Export Settings - %1").arg( TO_QSTRING(IsoName) ));
setWindowTitle(tr("Export Settings - %1").arg(TO_QSTRING(IsoName)));
}
else
{
Expand Down Expand Up @@ -83,20 +83,20 @@ void CExportGameDialog::InitUI(QString ExportDir)
// Info boxes
mpUI->GameTitleLineEdit->setText( TO_QSTRING(mGameTitle) );
mpUI->GameIdLineEdit->setText( TO_QSTRING(mGameID) );
mpUI->BuildVersionLineEdit->setText( QString("%1 (%2)").arg(mBuildVer).arg( TO_QSTRING(GameInfo.GetBuildName(mBuildVer, mRegion)) ));
mpUI->RegionLineEdit->setText( TEnumReflection<ERegion>::ConvertValueToString(mRegion) );
mpUI->BuildVersionLineEdit->setText(QStringLiteral("%1 (%2)").arg(mBuildVer).arg(TO_QSTRING(GameInfo.GetBuildName(mBuildVer, mRegion))));
mpUI->RegionLineEdit->setText(TEnumReflection<ERegion>::ConvertValueToString(mRegion));

// Disc tree widget
nod::IPartition *pPartition = mpDisc->getDataPartition();
ASSERT(pPartition);

QTreeWidgetItem *pTreeRoot = new QTreeWidgetItem((QTreeWidgetItem*) nullptr, QStringList(QString("Disc")));
QTreeWidgetItem* pTreeRoot = new QTreeWidgetItem((QTreeWidgetItem*)nullptr, QStringList(tr("Disc")));
mpUI->DiscFstTreeWidget->addTopLevelItem(pTreeRoot);

const nod::Node *pkDiscRoot = &pPartition->getFSTRoot();
RecursiveAddToTree(pkDiscRoot, pTreeRoot);

pTreeRoot->setIcon(0, QIcon(":/icons/Disc_16px.svg"));
pTreeRoot->setIcon(0, QIcon(QStringLiteral(":/icons/Disc_16px.svg")));
pTreeRoot->setExpanded(true);

// Signals and slots
Expand Down Expand Up @@ -228,7 +228,7 @@ bool CExportGameDialog::ValidateGame()
if (mGame == EGame::PrimeDemo || mGame == EGame::EchoesDemo || mGame == EGame::CorruptionProto)
{
// we cannot parent the error message box to ourselves because this window hasn't been shown
UICommon::ErrorMsg(parentWidget(), "The demo builds are currently not supported.");
UICommon::ErrorMsg(parentWidget(), tr("The demo builds are currently not supported."));
return false;
}

Expand All @@ -238,22 +238,22 @@ bool CExportGameDialog::ValidateGame()
bool CExportGameDialog::RequestWiiPortGame()
{
QDialog Dialog;
Dialog.setWindowTitle("Select Game");
Dialog.setWindowTitle(tr("Select Game"));

bool IsTrilogy = (mGame == EGame::Invalid);
bool HasMP1 = (IsTrilogy || mGame == EGame::Prime);
bool HasMP2 = (IsTrilogy || mGame == EGame::Echoes);
bool HasMP3 = IsTrilogy;

QString GameName = (IsTrilogy ? "Metroid Prime: Trilogy" : "Wii de Asobu");
QString LabelText = QString("You have selected a %1 ISO. Please pick a game to export:").arg(GameName);
QString GameName = (IsTrilogy ? tr("Metroid Prime: Trilogy") : tr("Wii de Asobu"));
QString LabelText = tr("You have selected a %1 ISO. Please pick a game to export:").arg(GameName);
QLabel Label(LabelText, &Dialog);

QComboBox ComboBox(&Dialog);
ComboBox.addItem("Front End");
if (HasMP1) ComboBox.addItem("Metroid Prime");
if (HasMP2) ComboBox.addItem("Metroid Prime 2: Echoes");
if (HasMP3) ComboBox.addItem("Metroid Prime 3: Corruption");
ComboBox.addItem(tr("Front End"));
if (HasMP1) ComboBox.addItem(tr("Metroid Prime"));
if (HasMP2) ComboBox.addItem(tr("Metroid Prime 2: Echoes"));
if (HasMP3) ComboBox.addItem(tr("Metroid Prime 3: Corruption"));
QDialogButtonBox ButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, &Dialog);
connect(&ButtonBox, SIGNAL(accepted()), &Dialog, SLOT(accept()));
connect(&ButtonBox, SIGNAL(rejected()), &Dialog, SLOT(reject()));
Expand Down Expand Up @@ -346,8 +346,8 @@ void CExportGameDialog::RecursiveAddToTree(const nod::Node *pkNode, QTreeWidgetI
});

// Add nodes to tree
static const QIcon skFileIcon = QIcon(":/icons/New_16px.svg");
static const QIcon skDirIcon = QIcon(":/icons/Open_16px.svg");
static const QIcon skFileIcon = QIcon(QStringLiteral(":/icons/New_16px.svg"));
static const QIcon skDirIcon = QIcon(QStringLiteral(":/icons/Open_16px.svg"));

for (auto Iter = NodeList.begin(); Iter != NodeList.end(); Iter++)
{
Expand All @@ -368,21 +368,21 @@ void CExportGameDialog::RecursiveAddToTree(const nod::Node *pkNode, QTreeWidgetI

void CExportGameDialog::BrowseOutputDirectory()
{
QString NewOutputDir = UICommon::OpenDirDialog(this, "Choose export directory");
QString NewOutputDir = UICommon::OpenDirDialog(this, tr("Choose export directory"));
if (!NewOutputDir.isEmpty()) mpUI->OutputDirectoryLineEdit->setText(NewOutputDir);
}

void CExportGameDialog::BrowseAssetNameMap()
{
QString Filter = "*." + TO_QSTRING(CAssetNameMap::GetExtension());
QString NewNameMap = UICommon::OpenFileDialog(this, "Choose Asset Name Map", Filter);
QString Filter = QStringLiteral("*.") + TO_QSTRING(CAssetNameMap::GetExtension());
QString NewNameMap = UICommon::OpenFileDialog(this, tr("Choose Asset Name Map"), Filter);
if (!NewNameMap.isEmpty()) mpUI->AssetNameMapLineEdit->setText(NewNameMap);
}

void CExportGameDialog::BrowseGameEditorInfo()
{
QString Filter = "*." + TO_QSTRING(CGameInfo::GetExtension());
QString NewGameInfo = UICommon::OpenFileDialog(this, "Choose Game Editor Info", Filter);
QString Filter = QStringLiteral("*.") + TO_QSTRING(CGameInfo::GetExtension());
QString NewGameInfo = UICommon::OpenFileDialog(this, tr("Choose Game Editor Info"), Filter);
if (!NewGameInfo.isEmpty()) mpUI->GameEditorInfoLineEdit->setText(NewGameInfo);
}

Expand All @@ -395,20 +395,20 @@ void CExportGameDialog::Export()
// Validate export dir
if (ExportDir.isEmpty())
{
UICommon::ErrorMsg(this, "Please specify an empty output directory!");
UICommon::ErrorMsg(this, tr("Please specify an empty output directory!"));
return;
}

else if (!FileUtil::IsEmpty( TO_TSTRING(ExportDir) ))
{
UICommon::ErrorMsg(this, "The output directory is not empty!");
UICommon::ErrorMsg(this, tr("The output directory is not empty!"));
return;
}

// Verify name map is valid
if (!NameMapPath.isEmpty() && !FileUtil::Exists(TO_TSTRING(NameMapPath)))
{
UICommon::ErrorMsg(this, "The Asset Name Map path is invalid!");
UICommon::ErrorMsg(this, tr("The Asset Name Map path is invalid!"));
return;
}

Expand All @@ -420,21 +420,21 @@ void CExportGameDialog::Export()

if (!LoadSuccess)
{
UICommon::ErrorMsg(this, "Failed to load the asset name map!");
UICommon::ErrorMsg(this, tr("Failed to load the asset name map!"));
return;
}

else if (!NameMap.IsValid())
{
UICommon::ErrorMsg(this, "The Asset Name Map is invalid and cannot be used! See the log for more information.");
UICommon::ErrorMsg(this, tr("The Asset Name Map is invalid and cannot be used! See the log for more information."));
return;
}
}

// Verify game info is valid
if (!GameInfoPath.isEmpty() && !FileUtil::Exists(TO_TSTRING(GameInfoPath)))
{
UICommon::ErrorMsg(this, "The Game Editor Info path is invalid!");
UICommon::ErrorMsg(this, tr("The Game Editor Info path is invalid!"));
return;
}

Expand All @@ -445,7 +445,7 @@ void CExportGameDialog::Export()

if (!LoadSuccess)
{
UICommon::ErrorMsg(this, "Failed to load game info!");
UICommon::ErrorMsg(this, tr("Failed to load game info!"));
return;
}
}
Expand All @@ -456,15 +456,17 @@ void CExportGameDialog::Export()
TString StrExportDir = TO_TSTRING(ExportDir);
StrExportDir.EnsureEndsWith('/');

CProgressDialog Dialog("Creating new game project", false, true, parentWidget());
CProgressDialog Dialog(tr("Creating new game project"), false, true, parentWidget());
QFuture<bool> Future = QtConcurrent::run(mpExporter, &CGameExporter::Export, mpDisc, StrExportDir, &NameMap, &GameInfo, &Dialog);
mExportSuccess = Dialog.WaitForResults(Future);

if (!mExportSuccess)
{
if (!Dialog.ShouldCancel())
UICommon::ErrorMsg(this, "Export failed!");
UICommon::ErrorMsg(this, tr("Export failed!"));
}
else
{
mNewProjectPath = TO_QSTRING(mpExporter->ProjectPath());
}
}
31 changes: 16 additions & 15 deletions src/Editor/CGeneratePropertyNamesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ void CGeneratePropertyNamesDialog::AddToIDPool(IProperty* pProperty)

uint32 ID = pProperty->ID();
const char* pkTypeName = pProperty->HashableTypeName();
mIdPairs << SPropertyIdTypePair { ID, pkTypeName };
mIdPairs << SPropertyIdTypePair{ID, pkTypeName};

QString ItemText = QString("%1 [%2]").arg( *TString::HexString(pProperty->ID(), 8, false) ).arg( pkTypeName );
mpUI->IdPoolList->addItem( ItemText );
QString ItemText = QStringLiteral("%1 [%2]").arg(*TString::HexString(pProperty->ID(), 8, false)).arg(pkTypeName);
mpUI->IdPoolList->addItem(ItemText);

// We probably don't want to call UpdateUI every single time we add a property, but
// we do need to call it somewhere to make sure the ID list shows up on the UI...
Expand Down Expand Up @@ -109,10 +109,10 @@ void CGeneratePropertyNamesDialog::closeEvent(QCloseEvent*)
/** Add an item to the suffix list */
void CGeneratePropertyNamesDialog::AddSuffix()
{
QListWidgetItem* pNewItem = new QListWidgetItem("New Suffix", mpUI->TypeSuffixesListWidget);
pNewItem->setFlags( Qt::ItemIsEditable |
Qt::ItemIsEnabled |
Qt::ItemIsSelectable );
QListWidgetItem* pNewItem = new QListWidgetItem(tr("New Suffix"), mpUI->TypeSuffixesListWidget);
pNewItem->setFlags(Qt::ItemIsEditable |
Qt::ItemIsEnabled |
Qt::ItemIsSelectable);
mpUI->TypeSuffixesListWidget->setCurrentItem(pNewItem, QItemSelectionModel::ClearAndSelect);
mpUI->TypeSuffixesListWidget->editItem(pNewItem);
}
Expand Down Expand Up @@ -272,11 +272,11 @@ void CGeneratePropertyNamesDialog::ApplyChanges()
{
// make sure the user really wants to do this
QString WarningText =
QString("Are you sure you want to rename %1 %2? This operation cannot be undone.")
.arg(mCheckedItems.size())
.arg(mCheckedItems.size() == 1 ? "property" : "properties");
tr("Are you sure you want to rename %1 %2? This operation cannot be undone.")
.arg(mCheckedItems.size())
.arg(mCheckedItems.size() == 1 ? tr("property") : tr("properties"));

bool ReallyRename = UICommon::YesNoQuestion(this, "Warning", WarningText);
bool ReallyRename = UICommon::YesNoQuestion(this, tr("Warning"), WarningText);

if (!ReallyRename)
{
Expand Down Expand Up @@ -369,11 +369,12 @@ void CGeneratePropertyNamesDialog::UpdateUI()
if (HasResults)
{
mpUI->NumSelectedLabel->setText(
QString("%1 names, %2 selected")
.arg(TotalItems)
.arg(mCheckedItems.size())
);
tr("%1 names, %2 selected")
.arg(TotalItems)
.arg(mCheckedItems.size()));
}
else
{
mpUI->NumSelectedLabel->clear();
}
}
Loading