mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-16 04:15:48 -04:00
Host: Backport translations cache
Note: You'll need a new command line for lupdate. ..\..\..\dep\msvc\qt\6.5.0\msvc2022_64\bin\lupdate.exe ../ ../../core/ ../../util/ -tr-function-alias QT_TRANSLATE_NOOP+=TRANSLATE,QT_TRANSLATE_NOOP+=TRANSLATE_SV,QT_TRANSLATE_NOOP+=TRANSLATE_STR,QT_TRANSLATE_NOOP+=TRANSLATE_FS,QT_TRANSLATE_N_NOOP3+=TRANSLATE_FMT,QT_TRANSLATE_NOOP+=TRANSLATE_NOOP -ts duckstation-qt_LANGUAGE.ts
This commit is contained in:
@ -434,13 +434,9 @@ void MainWindow::setDisplayFullscreen(const std::string& fullscreen_mode)
|
||||
{
|
||||
result = g_host_display->SetFullscreen(true, width, height, refresh_rate);
|
||||
if (result)
|
||||
{
|
||||
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Acquired exclusive fullscreen."), 10.0f);
|
||||
}
|
||||
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Acquired exclusive fullscreen."), 10.0f);
|
||||
else
|
||||
{
|
||||
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Failed to acquire exclusive fullscreen."), 10.0f);
|
||||
}
|
||||
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Failed to acquire exclusive fullscreen."), 10.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -629,7 +629,7 @@ void EmuThread::onDisplayWindowResized(int width, int height)
|
||||
if (m_is_exclusive_fullscreen && !g_host_display->IsFullscreen())
|
||||
{
|
||||
// we lost exclusive fullscreen, switch to borderless
|
||||
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Lost exclusive fullscreen."), 10.0f);
|
||||
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Lost exclusive fullscreen."), 10.0f);
|
||||
m_is_exclusive_fullscreen = false;
|
||||
m_is_fullscreen = false;
|
||||
m_lost_exclusive_fullscreen = true;
|
||||
@ -1507,19 +1507,6 @@ void EmuThread::wakeThread()
|
||||
QMetaObject::invokeMethod(m_event_loop, "quit", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
TinyString Host::TranslateString(const char* context, const char* str, const char* disambiguation /*= nullptr*/,
|
||||
int n /*= -1*/)
|
||||
{
|
||||
const QByteArray bytes(qApp->translate(context, str, disambiguation, n).toUtf8());
|
||||
return TinyString(bytes.constData(), bytes.size());
|
||||
}
|
||||
|
||||
std::string Host::TranslateStdString(const char* context, const char* str, const char* disambiguation /*= nullptr*/,
|
||||
int n /*= -1*/)
|
||||
{
|
||||
return qApp->translate(context, str, disambiguation, n).toStdString();
|
||||
}
|
||||
|
||||
void Host::ReportErrorAsync(const std::string_view& title, const std::string_view& message)
|
||||
{
|
||||
if (!title.empty() && !message.empty())
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include "qthost.h"
|
||||
|
||||
#include "core/host.h"
|
||||
|
||||
#include "util/imgui_manager.h"
|
||||
|
||||
#include "common/assert.h"
|
||||
@ -122,6 +124,25 @@ void QtHost::InstallTranslator()
|
||||
s_translators.push_back(translator);
|
||||
|
||||
UpdateGlyphRanges(language.toStdString());
|
||||
|
||||
Host::ClearTranslationCache();
|
||||
}
|
||||
|
||||
s32 Host::Internal::GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf,
|
||||
size_t tbuf_space)
|
||||
{
|
||||
// This is really awful. Thankfully we're caching the results...
|
||||
const std::string temp_context(context);
|
||||
const std::string temp_msg(msg);
|
||||
const QString translated_msg = qApp->translate(temp_context.c_str(), temp_msg.c_str());
|
||||
const QByteArray translated_utf8 = translated_msg.toUtf8();
|
||||
const size_t translated_size = translated_utf8.size();
|
||||
if (translated_size > tbuf_space)
|
||||
return -1;
|
||||
else if (translated_size > 0)
|
||||
std::memcpy(tbuf, translated_utf8.constData(), translated_size);
|
||||
|
||||
return static_cast<s32>(translated_size);
|
||||
}
|
||||
|
||||
static std::string QtHost::GetFontPath(const GlyphInfo* gi)
|
||||
|
@ -65,8 +65,8 @@ REM A good .ts file has been passed
|
||||
:goodfile
|
||||
ECHO Updating %filename%...
|
||||
ECHO.
|
||||
SET "linguist=..\..\..\dep\msvc\qt\6.1.0\msvc2019_64\bin"
|
||||
SET "context=.././ ../../core/ ../../frontend-common/ -tr-function-alias translate+=TranslateString -tr-function-alias translate+=TranslateStdString -tr-function-alias QT_TRANSLATE_NOOP+=TRANSLATABLE"
|
||||
SET "linguist=..\..\..\dep\msvc\qt\6.5.0\msvc2022_64\bin"
|
||||
SET "context=.././ ../../core/ ../../util/ -tr-function-alias QT_TRANSLATE_NOOP+=TRANSLATE,QT_TRANSLATE_NOOP+=TRANSLATE_SV,QT_TRANSLATE_NOOP+=TRANSLATE_STR,QT_TRANSLATE_NOOP+=TRANSLATE_FS,QT_TRANSLATE_N_NOOP3+=TRANSLATE_FMT,QT_TRANSLATE_NOOP+=TRANSLATE_NOOP"
|
||||
|
||||
"%linguist%\lupdate.exe" %context% -ts %filename%
|
||||
ECHO.
|
||||
|
@ -1,7 +1,7 @@
|
||||
@echo off
|
||||
|
||||
set "linguist=..\..\..\dep\msvc\qt\6.1.0\msvc2019_64\bin"
|
||||
set context=../ ../../core/ ../../frontend-common/ -tr-function-alias translate+=TranslateString -tr-function-alias translate+=TranslateStdString -tr-function-alias QT_TRANSLATE_NOOP+=TRANSLATABLE -pluralonly
|
||||
set "linguist=..\..\..\dep\msvc\qt\6.5.0\msvc2022_64\bin"
|
||||
set context=../ ../../core/ ../../util/ -tr-function-alias QT_TRANSLATE_NOOP+=TRANSLATE,QT_TRANSLATE_NOOP+=TRANSLATE_SV,QT_TRANSLATE_NOOP+=TRANSLATE_STR,QT_TRANSLATE_NOOP+=TRANSLATE_FS,QT_TRANSLATE_N_NOOP3+=TRANSLATE_FMT,QT_TRANSLATE_NOOP+=TRANSLATE_NOOP -pluralonly
|
||||
|
||||
"%linguist%\lupdate.exe" %context% -ts duckstation-qt_en.ts
|
||||
pause
|
||||
|
Reference in New Issue
Block a user