Skip to content

Commit

Permalink
增加翻译内容
Browse files Browse the repository at this point in the history
  • Loading branch information
MingYueRuYa committed Nov 30, 2024
1 parent 2c63559 commit 054be1b
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 12 deletions.
31 changes: 31 additions & 0 deletions env_tools/application.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "application.h"

#include <QIcon>
#include <QTranslator>

Application::Application(int& argc, char** argv) : QApplication(argc, argv) {
this->setWindowIcon(QIcon(":/WindbgConfig/images/icon.png"));
this->switch_language(Language::zh_CN);
}

Application::~Application() {}

bool Application::switch_language(Language lang) {
static QTranslator trans;
return this->_install_lang(trans, lang);
}

QString Application::AppName() const {
return "WinDbg Config Assistant";
}

bool Application::_install_lang(QTranslator& trans, Language lang) {
std::map<Language, QString> _map = {
{Language::zh_CN, ":/EnvTools/translator/env_tools_zh.qm"},
{Language::en_US, ":/EnvTools/translator/env_tools_en.qm"} };

if (!trans.load(_map[lang])) {
return false;
}
return qApp->installTranslator(&trans);
}
20 changes: 20 additions & 0 deletions env_tools/application.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <QApplication>

class Application : public QApplication {
Q_OBJECT

public:
enum class Language { zh_CN = 0, en_US = 1 };

public:
Application(int& argc, char** arg);
~Application();

bool switch_language(Language lang);
QString AppName() const;

private:
bool _install_lang(QTranslator& trans, Language lang);
};
69 changes: 69 additions & 0 deletions env_tools/env_tools.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// English (United States) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
// PNG
//

IDB_PNG1 PNG "res\\icon.png"

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

1 change: 1 addition & 0 deletions env_tools/env_tools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Qt5Version = 5.15.11.mt_static
SolutionGuid = {F1743090-610E-44E3-AD30-99699CD063BB}
EndGlobalSection
EndGlobal
19 changes: 15 additions & 4 deletions env_tools/env_tools.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
<Import Project="$(QtMsBuild)\qt_defaults.props" />
</ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
<QtInstall>5.15.11_x64_static</QtInstall>
<QtInstall>5.15.11.mt_static</QtInstall>
<QtModules>core;gui;widgets</QtModules>
<QtBuildConfig>debug</QtBuildConfig>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
<QtInstall>5.15.11_x64_static</QtInstall>
<QtInstall>5.15.11.mt_static</QtInstall>
<QtModules>core;gui;widgets</QtModules>
<QtBuildConfig>release</QtBuildConfig>
</PropertyGroup>
Expand All @@ -68,11 +68,17 @@
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
<OutputFile>$(OutDir)$(TargetName)d$(TargetExt)</OutputFile>
</Link>
<ClCompile>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Link>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
<ClCompile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
<ClCompile>
Expand Down Expand Up @@ -105,25 +111,30 @@
<ItemGroup>
<QtUic Include="EnvTools.ui" />
<QtMoc Include="EnvTools.h" />
<ClCompile Include="application.cpp" />
<ClCompile Include="EnvHelper.cpp" />
<ClCompile Include="EnvTools.cpp" />
<ClCompile Include="ListWidget.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<QtMoc Include="application.h" />
<ClInclude Include="EnvHelper.h" />
<ClInclude Include="resource.h" />
<QtMoc Include="ListWidget.h" />
</ItemGroup>
<ItemGroup>
<QtRcc Include="res\EnvTools.qrc" />
</ItemGroup>
<ItemGroup>
<Image Include="res\app.ico" />
<Image Include="res\icon.png" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="env_tools.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="res\app.ico" />
<Image Include="res\icon.png" />
<None Include="env_tools_zh.ts" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
Expand Down
21 changes: 16 additions & 5 deletions env_tools/env_tools.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<ClCompile Include="ListWidget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="application.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="EnvHelper.h">
Expand All @@ -56,17 +59,15 @@
<QtMoc Include="ListWidget.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="application.h">
<Filter>Header Files</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<QtRcc Include="res\EnvTools.qrc">
<Filter>Resource Files</Filter>
</QtRcc>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="env_tools.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="res\app.ico">
<Filter>Resource Files</Filter>
Expand All @@ -75,4 +76,14 @@
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="env_tools.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="env_tools_zh.ts">
<Filter>Translation Files</Filter>
</None>
</ItemGroup>
</Project>
7 changes: 4 additions & 3 deletions env_tools/main.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "EnvTools.h"
#include "application.h"
#include <QtWidgets/QApplication>

int main(int argc, char* argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication a(argc, argv);
a.setWindowIcon(QIcon(":/EnvTools/icon.png"));
Application app(argc, argv);
app.setWindowIcon(QIcon(":/EnvTools/icon.png"));
EnvTools w;
w.show();
return a.exec();
return app.exec();
}
1 change: 1 addition & 0 deletions env_tools/res/EnvTools.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/EnvTools">
<file>icon.png</file>
<file>translator/env_tools_zh.qm</file>
</qresource>
</RCC>
Binary file added env_tools/res/translator/env_tools_zh.qm
Binary file not shown.
File renamed without changes.
16 changes: 16 additions & 0 deletions env_tools/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by env_tools.rc
//
#define IDB_PNG1 101

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

0 comments on commit 054be1b

Please sign in to comment.