123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- #include "Clanguage.h"
- #pragma region 添加文案
- std::wstring CLanguage::GetContent(TextType textType)
- {
- std::wstring content = L"";
- switch (textType)
- {
- case TextType::Btn_Install:
- content = LoadLanguage(L"Install", L"开始安装", L"開始安裝");
- break;
- case TextType::Btn_CutomInstall:
- content = LoadLanguage(L"Installation Settings", L"自定义安装", L"自定義安裝");
- break;
- case TextType::Link_Install:
- content = LoadLanguage
- (
- L"Clicking \"Install\" means you agree to the {a https://www.pdfreaderpro.com/terms_of_service}Terms of Service{/a} and the {a https://www.pdfreaderpro.com/privacy-policy}Privacy Policy{/a}.",
- L"点击“开始安装”代表你同意{a https://www.pdfreaderpro.com/terms_of_service}服务条款{/a}和{a https://www.pdfreaderpro.com/privacy-policy}隐私权政策{/a}",
- L"點擊「開始安裝」代表你同意{a https://www.pdfreaderpro.com/terms_of_service}服務條款{/a}和{a https://www.pdfreaderpro.com/privacy-policy}隱私權政策{/a}"
- );
- break;
- case TextType::Txt_ByClickInstall:
- content = LoadLanguage
- (
- L"Clicking \"Install\" means you agree to the ",
- L"点击“开始安装”代表你同意",
- L"點擊「開始安裝」代表你同意"
- );
- break;
- case TextType::Btn_TermsService:
- content = LoadLanguage
- (
- L"Terms of Service ",
- L"服务条款",
- L"服務條款"
- );
- break;
-
- case TextType::Txt_And:
- content = LoadLanguage
- (
- L"and the ",
- L"和",
- L"和"
- );
- break;
- case TextType::Btn_PrivacyPolicy:
- content = LoadLanguage
- (
- L"Privacy Policy",
- L"隐私权政策",
- L"隱私權政策"
- );
- break;
- case TextType::Text_InstallPath:
- content = LoadLanguage(L"Installation Folder", L"安装路径", L"安裝路徑");
- break;
- case TextType::Btn_FilePath:
- content = LoadLanguage(L"Select Folder", L"选择文件夹", L"選擇資料夾");
- break;
- case TextType::Text_Installing:
- content = LoadLanguage(L"Installing, please wait...", L"安装中,请稍等...", L"安裝中,請稍後...");
- break;
- case TextType::Text_NoNetwork:
- content = LoadLanguage
- (
- L"No internet connection, please check your internet and try again later.",
- L"无网络连接,请检查网络并重试。",
- L"無網路連接,請檢查網路並重試。"
- );
- break;
- case TextType::Btn_OpenApp:
- content = LoadLanguage(L"Start Now", L"立即启动", L"立即啟動");
- break;
- case TextType::Btn_GoToFilesPath:
- content = LoadLanguage(L"Offline installer is saved in:", L"安装文件储存路径:", L"安裝檔案存儲路徑:");
- break;
- case TextType::MSG_IsExitApp:
- content = LoadLanguage(L"Are you sure to cancel the process? If you exit now, the program won't be installed.",
- L"请确认是否退出程序安装。退出后,安装进程将停止。",
- L"請確認是否退出程序安裝。退出後,安裝進程將停止。");
- break;
- case TextType::MSG_LatestVersion:
- content = LoadLanguage(
- L"Latest version already installed, you don't need to install again.",
- L"PDF Reader Pro 已是目前最新版本,无需再次安装。",
- L"PDF Reader Pro 已是目前最新版本,無需再次安裝。");
- break;
- case TextType::MSG_UpgradeVersion:
- content = LoadLanguage(
- L"Current version is too old. Would you like to update PDF Reader Pro to the latest version?",
- L"当前版本较低,是否升级至最新版本?",
- L"當前版本較低,是否升級至最新版本?");
- break;
- case TextType::MSG_OverHighVersion:
- content = LoadLanguage(
- L"A newer version of PDF Reader Pro has already been installed, if you want to install this version, please uninstall the current version.",
- L"已安装了更高版本的PDF Reader Pro, 请卸载后再安装此版本。",
- L"已安裝更高版本的PDF Reader Pro,請擔載後再安裝此版本。");
- break;
- case TextType::MSG_InstalledIsExitApp:
- content = LoadLanguage(
- L"PDF Reader Pro has been successfully installed, are you sure to start later?",
- L"程序已安装,是否稍后启动?",
- L"程式已安裝,是否稍後啟動?");
- break;
- case TextType::MSG_DiskNoSpace:
- content = LoadLanguage(
- L"Available space is less than 1GB, please change installation folder.",
- L"当前磁盘剩余空间不足1G,请修改安装路径",
- L"當前磁碟可用空間不足1G,請變更安裝路徑。");
- break;
- case TextType::MSG_BtnCancel:
- content = LoadLanguage(L"Cancel", L"取消", L"取消");
- break;
- case TextType::MSG_BtnOK:
- content = LoadLanguage(L"OK", L"确定", L"確定");
- break;
- case TextType::MSG_BtnYes:
- content = LoadLanguage(L"Yes", L"是", L"是");
- break;
- case TextType::MSG_BtnNo:
- content = LoadLanguage(L"No", L"否", L"否");
- break;
- case TextType::NONE:
- content = LoadLanguage(L"", L"", L"");
- break;
- case TextType::MSG_BtnOpenInstallationFolder:
- content = LoadLanguage(L"Open Installation Folder", L"打开安装目录", L"打開安裝目錄");
- break;
- case TextType::MSG_ContentOpenInstallationFolder:
- content = LoadLanguage(L"Installation Failed\nPlease find the installation folder and run \"PDFReaderPro.exe\" installation package again.", L"安装失败,请找到\"PDFReaderPro.exe\"安装包,点击重新安装", L"安裝失敗,請找到“PDFReaderPro.exe”安裝包,點擊重新安裝。");
- break;
- case TextType::MSG_ContentInstallFailed:
- content = LoadLanguage(L"Installation Failed\nDestination path too long, please try a location that has shorten path ", L"安装失败\n安装路径过长,请重新选择安装路径", L"安裝失敗\n安裝路徑過長,請重新選擇安裝路徑");
- break;
- case TextType::MSG_BtnBackHomePage:
- content = LoadLanguage(L"OK", L"返回", L"返回");
- break;
- case TextType::MSG_BtnUseDefaultPath:
- content = LoadLanguage(L"Use Default Path", L"使用默认安装路径", L"使用默認安裝路徑");
- break;
- case TextType::MSG_InstalledNetReStartSystem:
- content = LoadLanguage(L"Because the NetFramework was installed together with the software, you need to restart system to run PDF Reader Pro.", L"因安装软件的同时,也安装了NetFramework,当前设备需要重启系统,才能运行PDF Reader Pro", L"因安裝軟件的同時,也安裝了NetFramework,當前設備需要重啓系統,才能運行PDF Reader Pro.");
- break;
- case TextType::MSG_BtnRestartSystem:
- content = LoadLanguage(L"Restart", L"重新启动", L"重新啓動");
- break;
- default:
- break;
- }
- return content;
- }
- #pragma endregion
- #pragma region 多语言逻辑
- LanguageType CLanguage::CurrentLanguage = LanguageType::NONE;
- LanguageType CLanguage::LastLanguage = LanguageType::NONE;
- std::wstring CLanguage::GetText(TextType textType)
- {
- CurrentLanguage = GetLocalLanguage();
- return GetContent(textType);
- }
- std::wstring CLanguage::LoadLanguage(std::wstring EnStr, std::wstring zhsStr, std::wstring zhStr)
- {
- std::wstring content = L"";
- switch (CLanguage::CurrentLanguage)
- {
- case LanguageType::EN_US:
- content = EnStr;
- break;
- case LanguageType::ZH_CN:
- content = zhsStr;
- break;
- case LanguageType::ZH_TW:
- content = zhStr;
- break;
- default:
- content = EnStr;
- break;
- }
- return content;
- }
- LanguageType CLanguage::GetLocalLanguage(bool isGetText)
- {
- LanguageType language = LanguageType::EN_US;
- //加载文案时,不必要重新获取当前系统的语言种类
- if (isGetText)
- {
- if (CurrentLanguage != LanguageType::NONE && CurrentLanguage == LastLanguage)
- return CurrentLanguage;
- }
- LastLanguage = CurrentLanguage;
- // LCID lcid = GetSystemDefaultLCID();//系统语言(包括系统所有界面显示语言)
- LANGID lcid = ::GetUserDefaultUILanguage();//当前windows应用显示语言
- if (lcid == 0x409)
- {
- language = LanguageType::EN_US;
- }
- else if (lcid == 0x404)
- {
- language = LanguageType::ZH_TW;
- }
- else if (lcid == 0x804)
- {
- language = LanguageType::ZH_CN;
- }
- return language;
- }
- #pragma endregion
- #pragma region UI文案字符类型转换
- CDuiString CLanguage::GetDuiText(TextType textType)
- {
- CDuiString duiStr(CLanguage::GetText(textType).c_str());
- return duiStr;
- }
- #pragma endregion
|