mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-04-07 14:09:22 +08:00
[win-linux] updatesvc: translator revision
This commit is contained in:
@ -171,7 +171,7 @@ auto restartService()->void
|
||||
{
|
||||
wstring fileName = NS_File::appPath() + RESTART_BATCH;
|
||||
if (NS_File::fileExists(fileName) && !NS_File::removeFile(fileName)) {
|
||||
NS_Logger::WriteLog(_TR("An error occurred while deleting:") + _T(" ") + fileName, true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR2) + _T(" ") + fileName, true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ auto restartService()->void
|
||||
};
|
||||
|
||||
if (!NS_File::writeToFile(fileName, batch)) {
|
||||
NS_Logger::WriteLog(_TR("An error occurred while creating:") + _T(" ") + fileName, true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR3) + _T(" ") + fileName, true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ auto restartService()->void
|
||||
if (!CreateProcess(NULL, &fileName[0], NULL, NULL, FALSE,
|
||||
CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT, NULL, NULL, &si, &pi))
|
||||
{
|
||||
NS_Logger::WriteLog(_TR("An error occurred while restarting the service!"), true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR4), true);
|
||||
return;
|
||||
}
|
||||
CloseHandle(pi.hProcess);
|
||||
@ -667,7 +667,7 @@ void CSvcManager::startReplacingFiles(const tstring &packageType, const bool res
|
||||
tstring updSubPath = NS_File::fileExists(updPath + SUBFOLDER + APP_LAUNCH_NAME) ? updPath + SUBFOLDER : updPath;
|
||||
tstring tmpPath = NS_File::parentPath(appPath) + BACKUP_PATH;
|
||||
if (!NS_File::dirExists(updPath)) {
|
||||
NS_Logger::WriteLog(_TR("Update cancelled. Can't find folder:") + _T(" ") + updPath, true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR5) + _T(" ") + updPath, true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -678,7 +678,7 @@ void CSvcManager::startReplacingFiles(const tstring &packageType, const bool res
|
||||
tstring apps[] = {APP_LAUNCH_NAME, APP_LAUNCH_NAME2, APP_HELPER, DAEMON_NAME};
|
||||
for (int i = 0; i < sizeof(apps) / sizeof(apps[0]); i++) {
|
||||
if (!NS_File::verifyEmbeddedSignature(updSubPath + apps[i])) {
|
||||
NS_Logger::WriteLog(_TR("Update cancelled. The file signature is missing:") + _T(" ") + updSubPath + apps[i], true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR6) + _T(" ") + updSubPath + apps[i], true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -688,7 +688,7 @@ void CSvcManager::startReplacingFiles(const tstring &packageType, const bool res
|
||||
|
||||
// Check backup folder
|
||||
if (NS_File::dirExists(tmpPath) && !NS_File::removeDirRecursively(tmpPath)) {
|
||||
NS_Logger::WriteLog(_TR("Update cancelled. Can't delete folder:") + _T(" ") + tmpPath, true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR7) + _T(" ") + tmpPath, true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -707,7 +707,7 @@ void CSvcManager::startReplacingFiles(const tstring &packageType, const bool res
|
||||
sleep(500);
|
||||
|
||||
if (NS_File::isProcessRunning(app)) {
|
||||
NS_Logger::WriteLog(_TR("Update cancelled. The program is not closed:") + _T(" ") + app, true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR8) + _T(" ") + app, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -716,29 +716,29 @@ void CSvcManager::startReplacingFiles(const tstring &packageType, const bool res
|
||||
// Replace app path to Backup
|
||||
#ifdef _WIN32_UNUSED
|
||||
if (packageType == TEXT("portable") && !NS_File::dirExists(tmpPath) && !NS_File::makePath(tmpPath)) {
|
||||
NS_Logger::WriteLog(_TR("Update cancelled. Can't create folder:") + _T(" ") + tmpPath, true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR9) + _T(" ") + tmpPath, true);
|
||||
return;
|
||||
}
|
||||
if (!NS_File::replaceFolder(appPath, tmpPath, packageType != TEXT("portable"))) {
|
||||
#else
|
||||
if (!NS_File::replaceFolder(appPath, tmpPath, true)) {
|
||||
#endif
|
||||
NS_Logger::WriteLog(_TR("Update cancelled. Can't replace files to backup:") + _T(" ") + NS_Utils::GetLastErrorAsString(), true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR10) + _T(" ") + NS_Utils::GetLastErrorAsString(), true);
|
||||
if (NS_File::dirExists(tmpPath) && !NS_File::dirIsEmpty(tmpPath) && !NS_File::replaceFolder(tmpPath, appPath))
|
||||
NS_Logger::WriteLog(_TR("Can't restore files from backup!"), true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR11), true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Move update path to app path
|
||||
if (!NS_File::replaceFolder(updSubPath, appPath, true)) {
|
||||
NS_Logger::WriteLog(_TR("Update cancelled. Can't move updates to App path:") + _T(" ") + NS_Utils::GetLastErrorAsString(), true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR12) + _T(" ") + NS_Utils::GetLastErrorAsString(), true);
|
||||
|
||||
if (NS_File::dirExists(appPath) && !NS_File::removeDirRecursively(appPath)) {
|
||||
NS_Logger::WriteLog(_TR("An error occurred while remove App path:") + _T(" ") + NS_Utils::GetLastErrorAsString(), true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR13) + _T(" ") + NS_Utils::GetLastErrorAsString(), true);
|
||||
return;
|
||||
}
|
||||
if (!NS_File::replaceFolder(tmpPath, appPath, true))
|
||||
NS_Logger::WriteLog(_TR("An error occurred while restore files from backup:") + _T(" ") + NS_Utils::GetLastErrorAsString(), true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR14) + _T(" ") + NS_Utils::GetLastErrorAsString(), true);
|
||||
|
||||
NS_File::removeDirRecursively(updPath);
|
||||
return;
|
||||
@ -814,7 +814,7 @@ void CSvcManager::startReplacingFiles(const tstring &packageType, const bool res
|
||||
// Restart program
|
||||
if (restartAfterUpdate) {
|
||||
if (!NS_File::runProcess(appPath + APP_LAUNCH_NAME, _T("")))
|
||||
NS_Logger::WriteLog(_TR("An error occurred while restarting the program!"), true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR15), true);
|
||||
}
|
||||
|
||||
// Remove Backup dir
|
||||
@ -832,7 +832,7 @@ void CSvcManager::startReplacingService(const bool restartAfterUpdate)
|
||||
tstring updPath = NS_File::parentPath(appPath) + UPDATE_PATH;
|
||||
tstring updSubPath = NS_File::fileExists(updPath + SUBFOLDER + APP_LAUNCH_NAME) ? updPath + SUBFOLDER : updPath;
|
||||
if (!NS_File::dirExists(updPath)) {
|
||||
NS_Logger::WriteLog(_TR("Update cancelled. Can't find folder:") + _T(" ") + updPath, true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR5) + _T(" ") + updPath, true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -840,7 +840,7 @@ void CSvcManager::startReplacingService(const bool restartAfterUpdate)
|
||||
# ifndef DONT_VERIFY_SIGNATURE
|
||||
// Verify the signature of executable files
|
||||
if (!NS_File::verifyEmbeddedSignature(updSubPath + DAEMON_NAME)) {
|
||||
NS_Logger::WriteLog(_TR("Update cancelled. The file signature is missing:") + _T(" ") + updSubPath + DAEMON_NAME, true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR6) + _T(" ") + updSubPath + DAEMON_NAME, true);
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
@ -861,7 +861,7 @@ void CSvcManager::startReplacingService(const bool restartAfterUpdate)
|
||||
sleep(500);
|
||||
|
||||
if (NS_File::isProcessRunning(app)) {
|
||||
NS_Logger::WriteLog(_TR("Update cancelled. The program is not closed:") + _T(" ") + app, true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR8) + _T(" ") + app, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -884,7 +884,7 @@ void CSvcManager::startReplacingService(const bool restartAfterUpdate)
|
||||
// Restart program
|
||||
if (restartAfterUpdate) {
|
||||
if (!NS_File::runProcess(appPath + APP_LAUNCH_NAME, _T("")))
|
||||
NS_Logger::WriteLog(_TR("An error occurred while restarting the program!"), true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR15), true);
|
||||
}
|
||||
|
||||
// Remove Update dir
|
||||
@ -901,7 +901,7 @@ void CSvcManager::startInstallPackage()
|
||||
{
|
||||
// Verify the signature of executable files
|
||||
if (!NS_File::verifyEmbeddedSignature(m_packageData->fileName)) {
|
||||
NS_Logger::WriteLog(_TR("Update cancelled. The file signature is missing:") + _T(" ") + m_packageData->fileName, true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR6) + _T(" ") + m_packageData->fileName, true);
|
||||
return;
|
||||
}
|
||||
tstring args;
|
||||
@ -916,6 +916,6 @@ void CSvcManager::startInstallPackage()
|
||||
args += _T("/LANG=") + NS_Utils::GetAppLanguage();
|
||||
}
|
||||
if (!NS_File::runProcess(m_packageData->fileType == _T("msi") ? _T("msiexec.exe") : m_packageData->fileName, args))
|
||||
NS_Logger::WriteLog(_TR("An error occurred while start install updates!"), true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR18), true);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
CApplication::CApplication()
|
||||
{
|
||||
if (SDL_Init(SDL_INIT_EVENTS | SDL_INIT_TIMER) != 0)
|
||||
NS_Logger::WriteLog(_TR("SDL init error:") + _T(" ") + SDL_GetError(), true);
|
||||
NS_Logger::WriteLog(_TR(MESSAGE_TEXT_ERR16) + _T(" ") + SDL_GetError(), true);
|
||||
}
|
||||
|
||||
CApplication::~CApplication()
|
||||
|
||||
@ -134,24 +134,26 @@ tstring Translator::tr(const char *str)
|
||||
if (is_translations_valid) {
|
||||
for (auto &strIdPair : translMap) {
|
||||
//LocaleMap locMap = strIdPair.second;
|
||||
for (LocaleMap::const_iterator it = strIdPair.second.begin(); it != strIdPair.second.end(); ++it) {
|
||||
// for (LocaleMap::const_iterator it = strIdPair.second.begin(); it != strIdPair.second.end(); ++it) {
|
||||
//wcout << L"\n\n" << translatedStr << L"\n" << it->second;
|
||||
if (it->second == translatedStr) {
|
||||
if (strIdPair.first == translatedStr) {
|
||||
if (strIdPair.second.find(langName) != strIdPair.second.end())
|
||||
translatedStr = strIdPair.second[langName];
|
||||
return strIdPair.second[langName];
|
||||
else {
|
||||
tstring primaryLangAndScript = getPrimaryLang(langName, true);
|
||||
if (strIdPair.second.find(primaryLangAndScript) != strIdPair.second.end())
|
||||
translatedStr = strIdPair.second[primaryLangAndScript];
|
||||
return strIdPair.second[primaryLangAndScript];
|
||||
else {
|
||||
tstring primaryLang = getPrimaryLang(langName);
|
||||
if (strIdPair.second.find(primaryLang) != strIdPair.second.end())
|
||||
translatedStr = strIdPair.second[primaryLang];
|
||||
return strIdPair.second[primaryLang];
|
||||
}
|
||||
}
|
||||
if (strIdPair.second.find(L"en") != strIdPair.second.end())
|
||||
return strIdPair.second[L"en"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
return translatedStr;
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
# define tstring std::string
|
||||
#endif
|
||||
|
||||
#define _TR(str) Translator::tr(#str)
|
||||
|
||||
using std::unordered_map;
|
||||
|
||||
typedef unordered_map<tstring, tstring> LocaleMap;
|
||||
|
||||
@ -137,7 +137,7 @@ namespace NS_Utils
|
||||
|
||||
gtk_init(NULL, NULL);
|
||||
GtkWidget *dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", str.c_str());
|
||||
string prod_name = _TR(VER_PRODUCTNAME_STR);
|
||||
string prod_name = _TR(CAPTION_TEXT);
|
||||
gtk_window_set_title(GTK_WINDOW(dialog), prod_name.c_str());
|
||||
gtk_window_set_keep_above(GTK_WINDOW(dialog), true);
|
||||
gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 150);
|
||||
|
||||
@ -41,10 +41,8 @@ using std::string;
|
||||
using std::to_string;
|
||||
using std::list;
|
||||
|
||||
#define _TR(str) Translator::tr(str)
|
||||
|
||||
#define FUNCTION_INFO string(__FUNCTION__) + " Line: " + to_string(__LINE__)
|
||||
#define DEFAULT_ERROR_MESSAGE _TR("An error occurred:") + " " + FUNCTION_INFO
|
||||
#define DEFAULT_ERROR_MESSAGE _TR(MESSAGE_TEXT_ERR1) + " " + FUNCTION_INFO
|
||||
#define ADVANCED_ERROR_MESSAGE DEFAULT_ERROR_MESSAGE + \
|
||||
" " + NS_Utils::GetLastErrorAsString()
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ int __cdecl _tmain (int argc, TCHAR *argv[])
|
||||
};
|
||||
|
||||
if (StartServiceCtrlDispatcher(DispatchTable) == 0) {
|
||||
NS_Utils::ShowMessage(_TR("ServiceCtrlDispatcher returned error:") + _T(" ") + NS_Utils::GetLastErrorAsString(), true);
|
||||
NS_Utils::ShowMessage(_TR(MESSAGE_TEXT_ERR17) + _T(" ") + NS_Utils::GetLastErrorAsString(), true);
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
|
||||
@ -174,7 +174,7 @@ namespace NS_Utils
|
||||
{
|
||||
if (showError)
|
||||
str += L" " + GetLastErrorAsString();
|
||||
wstring prod_name = _TR(VER_PRODUCTNAME_STR);
|
||||
wstring prod_name = _TR(CAPTION_TEXT);
|
||||
wchar_t *title = const_cast<LPTSTR>(prod_name.c_str());
|
||||
if (isRunAsApp()) {
|
||||
MessageBox(NULL, str.c_str(), title, MB_ICONERROR | MB_SERVICE_NOTIFICATION_NT3X | MB_SETFOREGROUND);
|
||||
|
||||
@ -41,10 +41,8 @@ using std::wstring;
|
||||
using std::to_wstring;
|
||||
using std::list;
|
||||
|
||||
#define _TR(str) Translator::tr(str)
|
||||
|
||||
#define FUNCTION_INFO wstring(TEXT(__FUNCTION__)) + L" Line: " + to_wstring(__LINE__)
|
||||
#define DEFAULT_ERROR_MESSAGE _TR("An error occurred:") + L" " + FUNCTION_INFO
|
||||
#define DEFAULT_ERROR_MESSAGE _TR(MESSAGE_TEXT_ERR1) + L" " + FUNCTION_INFO
|
||||
#define ADVANCED_ERROR_MESSAGE DEFAULT_ERROR_MESSAGE + \
|
||||
L" " + NS_Utils::GetLastErrorAsString()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user