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:
Stenzek 2023-08-20 00:08:03 +10:00
parent 1ec6aee5bf
commit e57ad0b6aa
28 changed files with 499 additions and 413 deletions

View file

@ -505,8 +505,7 @@ void Achievements::UpdateSettings(const Settings& old_config)
else if (!s_challenge_mode && g_settings.achievements_challenge_mode)
{
ImGuiFullscreen::ShowToast(
std::string(), Host::TranslateStdString("Achievements", "Hardcore mode will be enabled on system reset."),
10.0f);
std::string(), TRANSLATE_STR("Achievements", "Hardcore mode will be enabled on system reset."), 10.0f);
}
}
@ -534,11 +533,9 @@ bool Achievements::ConfirmChallengeModeDisable(const char* trigger)
// I really hope this doesn't deadlock :/
const bool confirmed = Host::ConfirmMessage(
Host::TranslateString("Achievements", "Confirm Hardcore Mode"),
fmt::format(Host::TranslateString("Achievements",
"{0} cannot be performed while hardcore mode is active. Do you "
"want to disable hardcore mode? {0} will be cancelled if you select No.")
.GetCharArray(),
TRANSLATE("Achievements", "Confirm Hardcore Mode"),
fmt::format(TRANSLATE_FS("Achievements", "{0} cannot be performed while hardcore mode is active. Do you "
"want to disable hardcore mode? {0} will be cancelled if you select No."),
trigger));
if (!confirmed)
return false;
@ -586,8 +583,8 @@ void Achievements::SetChallengeMode(bool enabled)
if (HasActiveGame())
{
ImGuiFullscreen::ShowToast(std::string(),
enabled ? Host::TranslateStdString("Achievements", "Hardcore mode is now enabled.") :
Host::TranslateStdString("Achievements", "Hardcore mode is now disabled."),
enabled ? TRANSLATE_STR("Achievements", "Hardcore mode is now enabled.") :
TRANSLATE_STR("Achievements", "Hardcore mode is now disabled."),
10.0f);
}
@ -1004,21 +1001,20 @@ void Achievements::DisplayAchievementSummary()
{
std::string title;
if (ChallengeModeActive())
title = fmt::format(Host::TranslateString("Achievements", "{} (Hardcore Mode)").GetCharArray(), s_game_title);
title = fmt::format(TRANSLATE_FS("Achievements", "{} (Hardcore Mode)"), s_game_title);
else
title = s_game_title;
std::string summary;
if (GetAchievementCount() > 0)
{
summary = fmt::format(
Host::TranslateString("Achievements", "You have earned {} of {} achievements, and {} of {} points.")
.GetCharArray(),
GetUnlockedAchiementCount(), GetAchievementCount(), GetCurrentPointsForGame(), GetMaximumPointsForGame());
summary = fmt::format(TRANSLATE_FS("Achievements", "You have earned {} of {} achievements, and {} of {} points."),
GetUnlockedAchiementCount(), GetAchievementCount(), GetCurrentPointsForGame(),
GetMaximumPointsForGame());
}
else
{
summary = Host::TranslateStdString("Achievements", "This game has no achievements.");
summary = TRANSLATE_STR("Achievements", "This game has no achievements.");
}
if (GetLeaderboardCount() > 0)
{
@ -1769,9 +1765,9 @@ void Achievements::SubmitLeaderboardCallback(s32 status_code, std::string conten
rc_runtime_format_lboard_value(submitted_score, sizeof(submitted_score), response.submitted_score, lb->format);
rc_runtime_format_lboard_value(best_score, sizeof(best_score), response.best_score, lb->format);
std::string summary = fmt::format(
Host::TranslateString("Achievements", "Your Score: {} (Best: {})\nLeaderboard Position: {} of {}").GetCharArray(),
submitted_score, best_score, response.new_rank, response.num_entries);
std::string summary =
fmt::format(TRANSLATE_FS("Achievements", "Your Score: {} (Best: {})\nLeaderboard Position: {} of {}"),
submitted_score, best_score, response.new_rank, response.num_entries);
ImGuiFullscreen::AddNotification(10.0f, lb->title, std::move(summary), s_game_icon);

View file

@ -57,8 +57,8 @@ void AnalogController::Reset()
{
Host::AddIconOSDMessage(
fmt::format("Controller{}AnalogMode", m_index), ICON_FA_GAMEPAD,
Host::TranslateStdString(
"OSDMessage", "Analog mode forcing is disabled by game settings. Controller will start in digital mode."),
TRANSLATE_STR("OSDMessage",
"Analog mode forcing is disabled by game settings. Controller will start in digital mode."),
10.0f);
}
else
@ -106,14 +106,12 @@ bool AnalogController::DoState(StateWrapper& sw, bool apply_input_state)
if (old_analog_mode != m_analog_mode)
{
Host::AddIconOSDMessage(
fmt::format("Controller{}AnalogMode", m_index), ICON_FA_GAMEPAD,
fmt::format((m_analog_mode ?
Host::TranslateString("AnalogController", "Controller {} switched to analog mode.") :
Host::TranslateString("AnalogController", "Controller {} switched to digital mode."))
.GetCharArray(),
m_index + 1u),
5.0f);
Host::AddIconOSDMessage(fmt::format("Controller{}AnalogMode", m_index), ICON_FA_GAMEPAD,
fmt::format(m_analog_mode ?
TRANSLATE_FS("AnalogController", "Controller {} switched to analog mode.") :
TRANSLATE_FS("AnalogController", "Controller {} switched to digital mode."),
m_index + 1u),
5.0f);
}
}
return true;
@ -294,13 +292,12 @@ void AnalogController::SetAnalogMode(bool enabled, bool show_message)
Log_InfoPrintf("Controller %u switched to %s mode.", m_index + 1u, enabled ? "analog" : "digital");
if (show_message)
{
Host::AddIconOSDMessage(
fmt::format("Controller{}AnalogMode", m_index), ICON_FA_GAMEPAD,
fmt::format((enabled ? Host::TranslateString("AnalogController", "Controller {} switched to analog mode.") :
Host::TranslateString("AnalogController", "Controller {} switched to digital mode."))
.GetCharArray(),
m_index + 1u),
5.0f);
Host::AddIconOSDMessage(fmt::format("Controller{}AnalogMode", m_index), ICON_FA_GAMEPAD,
fmt::format(enabled ?
TRANSLATE_FS("AnalogController", "Controller {} switched to analog mode.") :
TRANSLATE_FS("AnalogController", "Controller {} switched to digital mode."),
m_index + 1u),
5.0f);
}
m_analog_mode = enabled;
}
@ -311,10 +308,9 @@ void AnalogController::ProcessAnalogModeToggle()
{
Host::AddIconOSDMessage(
fmt::format("Controller{}AnalogMode", m_index), ICON_FA_GAMEPAD,
fmt::format((m_analog_mode ?
Host::TranslateString("AnalogController", "Controller {} is locked to analog mode by the game.") :
Host::TranslateString("AnalogController", "Controller {} is locked to digital mode by the game."))
.GetCharArray(),
fmt::format(m_analog_mode ?
TRANSLATE_FS("AnalogController", "Controller {} is locked to analog mode by the game.") :
TRANSLATE_FS("AnalogController", "Controller {} is locked to digital mode by the game."),
m_index + 1u),
5.0f);
}
@ -840,11 +836,11 @@ static const SettingInfo s_settings[] = {
{SettingInfo::Type::Boolean, "AnalogDPadInDigitalMode",
TRANSLATE_NOOP("AnalogController", "Use Analog Sticks for D-Pad in Digital Mode"),
TRANSLATE_NOOP("AnalogController",
"Allows you to use the analog sticks to control the d-pad in digital mode, as well as the buttons."),
"Allows you to use the analog sticks to control the d-pad in digital mode, as well as the buttons."),
"true"},
{SettingInfo::Type::Float, "AnalogDeadzone", TRANSLATE_NOOP("AnalogController", "Analog Deadzone"),
TRANSLATE_NOOP("AnalogController",
"Sets the analog stick deadzone, i.e. the fraction of the stick movement which will be ignored."),
"Sets the analog stick deadzone, i.e. the fraction of the stick movement which will be ignored."),
"0.00f", "0.00f", "1.00f", "0.01f", "%.0f%%", nullptr, 100.0f},
{SettingInfo::Type::Float, "AnalogSensitivity", TRANSLATE_NOOP("AnalogController", "Analog Sensitivity"),
TRANSLATE_NOOP(
@ -854,15 +850,15 @@ static const SettingInfo s_settings[] = {
"1.33f", "0.01f", "2.00f", "0.01f", "%.0f%%", nullptr, 100.0f},
{SettingInfo::Type::Float, "ButtonDeadzone", TRANSLATE_NOOP("AnalogController", "Button/Trigger Deadzone"),
TRANSLATE_NOOP("AnalogController", "Sets the deadzone for activating buttons/triggers, "
"i.e. the fraction of the trigger which will be ignored."),
"i.e. the fraction of the trigger which will be ignored."),
"0.25", "0.00", "1.00", "0.01", "%.0f%%", nullptr, 100.0f},
{SettingInfo::Type::Integer, "VibrationBias", TRANSLATE_NOOP("AnalogController", "Vibration Bias"),
TRANSLATE_NOOP("AnalogController", "Sets the rumble bias value. If rumble in some games is too weak or not "
"functioning, try increasing this value."),
"functioning, try increasing this value."),
"8", "0", "255", "1", "%d", nullptr, 1.0f},
{SettingInfo::Type::IntegerList, "InvertLeftStick", TRANSLATE_NOOP("AnalogController", "Invert Left Stick"),
TRANSLATE_NOOP("AnalogController", "Inverts the direction of the left analog stick."), "0", "0", "3", nullptr, nullptr,
s_invert_settings, 0.0f},
TRANSLATE_NOOP("AnalogController", "Inverts the direction of the left analog stick."), "0", "0", "3", nullptr,
nullptr, s_invert_settings, 0.0f},
{SettingInfo::Type::IntegerList, "InvertRightStick", TRANSLATE_NOOP("AnalogController", "Invert Right Stick"),
TRANSLATE_NOOP("AnalogController", "Inverts the direction of the right analog stick."), "0", "0", "3", nullptr,
nullptr, s_invert_settings, 0.0f},

View file

@ -59,8 +59,8 @@ bool AnalogJoystick::DoState(StateWrapper& sw, bool apply_input_state)
{
Host::AddFormattedOSDMessage(5.0f,
m_analog_mode ?
Host::TranslateString("AnalogJoystick", "Controller %u switched to analog mode.") :
Host::TranslateString("AnalogJoystick", "Controller %u switched to digital mode."),
TRANSLATE("AnalogJoystick", "Controller %u switched to analog mode.") :
TRANSLATE("AnalogJoystick", "Controller %u switched to digital mode."),
m_index + 1u);
}
return true;
@ -235,8 +235,8 @@ void AnalogJoystick::ToggleAnalogMode()
Log_InfoPrintf("Joystick %u switched to %s mode.", m_index + 1u, m_analog_mode ? "analog" : "digital");
Host::AddFormattedOSDMessage(5.0f,
m_analog_mode ?
Host::TranslateString("AnalogJoystick", "Controller %u switched to analog mode.") :
Host::TranslateString("AnalogJoystick", "Controller %u switched to digital mode."),
TRANSLATE("AnalogJoystick", "Controller %u switched to analog mode.") :
TRANSLATE("AnalogJoystick", "Controller %u switched to digital mode."),
m_index + 1u);
}

View file

@ -303,7 +303,7 @@ std::optional<std::vector<u8>> BIOS::GetBIOSImage(ConsoleRegion region)
if (!image.has_value())
{
Host::ReportFormattedErrorAsync(
"Error", Host::TranslateString("HostInterface", "Failed to load configured BIOS file '%s'"), bios_name.c_str());
"Error", TRANSLATE("HostInterface", "Failed to load configured BIOS file '%s'"), bios_name.c_str());
return std::nullopt;
}
@ -358,7 +358,7 @@ std::optional<std::vector<u8>> BIOS::FindBIOSImageInDirectory(ConsoleRegion regi
if (!fallback_image.has_value())
{
Host::ReportFormattedErrorAsync("Error",
Host::TranslateString("HostInterface", "No BIOS image found for %s region"),
TRANSLATE("HostInterface", "No BIOS image found for %s region"),
Settings::GetConsoleRegionDisplayName(region));
return std::nullopt;
}

View file

@ -780,7 +780,7 @@ bool CDROM::PrecacheMedia()
if (m_reader.GetMedia()->HasSubImages() && m_reader.GetMedia()->GetSubImageCount() > 1)
{
Host::AddFormattedOSDMessage(
15.0f, Host::TranslateString("OSDMessage", "CD image preloading not available for multi-disc image '%s'"),
15.0f, TRANSLATE("OSDMessage", "CD image preloading not available for multi-disc image '%s'"),
FileSystem::GetDisplayNameFromPath(m_reader.GetMedia()->GetFileName()).c_str());
return false;
}
@ -788,7 +788,7 @@ bool CDROM::PrecacheMedia()
HostInterfaceProgressCallback callback;
if (!m_reader.Precache(&callback))
{
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Precaching CD image failed, it may be unreliable."),
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Precaching CD image failed, it may be unreliable."),
15.0f);
return false;
}

View file

@ -575,8 +575,7 @@ void CommonHost::UpdateDiscordPresence(bool rich_presence_only)
SmallString details_string;
if (!System::IsShutdown())
{
details_string.AppendFormattedString("%s (%s)", System::GetGameTitle().c_str(),
System::GetGameSerial().c_str());
details_string.AppendFormattedString("%s (%s)", System::GetGameTitle().c_str(), System::GetGameSerial().c_str());
}
else
{
@ -692,8 +691,8 @@ DEFINE_HOTKEY("FastForward", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOO
System::SetFastForwardEnabled(pressed > 0);
})
DEFINE_HOTKEY("ToggleFastForward", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOOP("Hotkeys", "Toggle Fast Forward"),
[](s32 pressed) {
DEFINE_HOTKEY("ToggleFastForward", TRANSLATE_NOOP("Hotkeys", "General"),
TRANSLATE_NOOP("Hotkeys", "Toggle Fast Forward"), [](s32 pressed) {
if (!pressed)
System::SetFastForwardEnabled(!System::IsFastForwardEnabled());
})
@ -737,28 +736,26 @@ DEFINE_HOTKEY("Screenshot", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOOP
})
#if !defined(__ANDROID__) && defined(WITH_CHEEVOS)
DEFINE_HOTKEY("OpenAchievements", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOOP("Hotkeys", "Open Achievement List"),
[](s32 pressed) {
DEFINE_HOTKEY("OpenAchievements", TRANSLATE_NOOP("Hotkeys", "General"),
TRANSLATE_NOOP("Hotkeys", "Open Achievement List"), [](s32 pressed) {
if (!pressed)
{
if (!FullscreenUI::OpenAchievementsWindow())
{
Host::AddOSDMessage(
Host::TranslateStdString("OSDMessage", "Achievements are disabled or unavailable for game."),
10.0f);
TRANSLATE_STR("OSDMessage", "Achievements are disabled or unavailable for game."), 10.0f);
}
}
})
DEFINE_HOTKEY("OpenLeaderboards", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOOP("Hotkeys", "Open Leaderboard List"),
[](s32 pressed) {
DEFINE_HOTKEY("OpenLeaderboards", TRANSLATE_NOOP("Hotkeys", "General"),
TRANSLATE_NOOP("Hotkeys", "Open Leaderboard List"), [](s32 pressed) {
if (!pressed)
{
if (!FullscreenUI::OpenLeaderboardsWindow())
{
Host::AddOSDMessage(
Host::TranslateStdString("OSDMessage", "Leaderboards are disabled or unavailable for game."),
10.0f);
TRANSLATE_STR("OSDMessage", "Leaderboards are disabled or unavailable for game."), 10.0f);
}
}
})
@ -769,27 +766,29 @@ DEFINE_HOTKEY("Reset", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotk
Host::RunOnCPUThread(System::ResetSystem);
})
DEFINE_HOTKEY("ChangeDisc", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Change Disc"), [](s32 pressed) {
if (!pressed && System::IsValid() && System::HasMediaSubImages())
{
const u32 current = System::GetMediaSubImageIndex();
const u32 next = (current + 1) % System::GetMediaSubImageCount();
if (current != next)
Host::RunOnCPUThread([next]() { System::SwitchMediaSubImage(next); });
}
})
DEFINE_HOTKEY("SwapMemoryCards", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Swap Memory Card Slots"),
DEFINE_HOTKEY("ChangeDisc", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Change Disc"),
[](s32 pressed) {
if (!pressed && System::IsValid() && System::HasMediaSubImages())
{
const u32 current = System::GetMediaSubImageIndex();
const u32 next = (current + 1) % System::GetMediaSubImageCount();
if (current != next)
Host::RunOnCPUThread([next]() { System::SwitchMediaSubImage(next); });
}
})
DEFINE_HOTKEY("SwapMemoryCards", TRANSLATE_NOOP("Hotkeys", "System"),
TRANSLATE_NOOP("Hotkeys", "Swap Memory Card Slots"), [](s32 pressed) {
if (!pressed)
System::SwapMemoryCards();
})
#ifndef __ANDROID__
DEFINE_HOTKEY("FrameStep", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Frame Step"), [](s32 pressed) {
if (!pressed)
System::DoFrameStep();
})
DEFINE_HOTKEY("FrameStep", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Frame Step"),
[](s32 pressed) {
if (!pressed)
System::DoFrameStep();
})
#endif
DEFINE_HOTKEY("Rewind", TRANSLATE_NOOP("Hotkeys", "System"), TRANSLATE_NOOP("Hotkeys", "Rewind"), [](s32 pressed) {
@ -827,14 +826,14 @@ DEFINE_HOTKEY("ToggleOverclocking", TRANSLATE_NOOP("Hotkeys", "System"),
((static_cast<double>(System::MASTER_CLOCK) * static_cast<double>(percent)) / 100.0) / 1000000.0;
Host::AddKeyedFormattedOSDMessage(
"ToggleOverclocking", 5.0f,
Host::TranslateString("OSDMessage", "CPU clock speed control enabled (%u%% / %.3f MHz)."),
percent, clock_speed);
TRANSLATE("OSDMessage", "CPU clock speed control enabled (%u%% / %.3f MHz)."), percent,
clock_speed);
}
else
{
Host::AddKeyedFormattedOSDMessage(
"ToggleOverclocking", 5.0f,
Host::TranslateString("OSDMessage", "CPU clock speed control disabled (%.3f MHz)."),
TRANSLATE("OSDMessage", "CPU clock speed control disabled (%.3f MHz)."),
static_cast<double>(System::MASTER_CLOCK) / 1000000.0);
}
}
@ -847,7 +846,7 @@ DEFINE_HOTKEY("IncreaseEmulationSpeed", TRANSLATE_NOOP("Hotkeys", "System"),
g_settings.emulation_speed += 0.1f;
System::UpdateSpeedLimiterState();
Host::AddKeyedFormattedOSDMessage("EmulationSpeedChange", 5.0f,
Host::TranslateString("OSDMessage", "Emulation speed set to %u%%."),
TRANSLATE("OSDMessage", "Emulation speed set to %u%%."),
static_cast<u32>(std::lround(g_settings.emulation_speed * 100.0f)));
}
})
@ -859,7 +858,7 @@ DEFINE_HOTKEY("DecreaseEmulationSpeed", TRANSLATE_NOOP("Hotkeys", "System"),
g_settings.emulation_speed = std::max(g_settings.emulation_speed - 0.1f, 0.1f);
System::UpdateSpeedLimiterState();
Host::AddKeyedFormattedOSDMessage("EmulationSpeedChange", 5.0f,
Host::TranslateString("OSDMessage", "Emulation speed set to %u%%."),
TRANSLATE("OSDMessage", "Emulation speed set to %u%%."),
static_cast<u32>(std::lround(g_settings.emulation_speed * 100.0f)));
}
})
@ -871,7 +870,7 @@ DEFINE_HOTKEY("ResetEmulationSpeed", TRANSLATE_NOOP("Hotkeys", "System"),
g_settings.emulation_speed = Host::GetFloatSettingValue("Main", "EmulationSpeed", 1.0f);
System::UpdateSpeedLimiterState();
Host::AddKeyedFormattedOSDMessage("EmulationSpeedChange", 5.0f,
Host::TranslateString("OSDMessage", "Emulation speed set to %u%%."),
TRANSLATE("OSDMessage", "Emulation speed set to %u%%."),
static_cast<u32>(std::lround(g_settings.emulation_speed * 100.0f)));
}
})
@ -893,8 +892,8 @@ DEFINE_HOTKEY("TogglePGXP", TRANSLATE_NOOP("Hotkeys", "Graphics"), TRANSLATE_NOO
System::ClearMemorySaveStates();
Host::AddKeyedOSDMessage("TogglePGXP",
g_settings.gpu_pgxp_enable ?
Host::TranslateStdString("OSDMessage", "PGXP is now enabled.") :
Host::TranslateStdString("OSDMessage", "PGXP is now disabled."),
TRANSLATE_STR("OSDMessage", "PGXP is now enabled.") :
TRANSLATE_STR("OSDMessage", "PGXP is now disabled."),
5.0f);
if (g_settings.gpu_pgxp_enable)
@ -937,8 +936,7 @@ DEFINE_HOTKEY("ReloadTextureReplacements", TRANSLATE_NOOP("Hotkeys", "Graphics")
if (!pressed && System::IsValid())
{
Host::AddKeyedOSDMessage("ReloadTextureReplacements",
Host::TranslateStdString("OSDMessage", "Texture replacements reloaded."),
10.0f);
TRANSLATE_STR("OSDMessage", "Texture replacements reloaded."), 10.0f);
g_texture_replacements.Reload();
}
})
@ -961,12 +959,11 @@ DEFINE_HOTKEY("TogglePGXPDepth", TRANSLATE_NOOP("Hotkeys", "Graphics"),
g_gpu->UpdateSettings();
g_gpu->ResetGraphicsAPIState();
System::ClearMemorySaveStates();
Host::AddKeyedOSDMessage(
"TogglePGXPDepth",
g_settings.gpu_pgxp_depth_buffer ?
Host::TranslateStdString("OSDMessage", "PGXP Depth Buffer is now enabled.") :
Host::TranslateStdString("OSDMessage", "PGXP Depth Buffer is now disabled."),
5.0f);
Host::AddKeyedOSDMessage("TogglePGXPDepth",
g_settings.gpu_pgxp_depth_buffer ?
TRANSLATE_STR("OSDMessage", "PGXP Depth Buffer is now enabled.") :
TRANSLATE_STR("OSDMessage", "PGXP Depth Buffer is now disabled."),
5.0f);
}
})
@ -984,8 +981,8 @@ DEFINE_HOTKEY("TogglePGXPCPU", TRANSLATE_NOOP("Hotkeys", "Graphics"), TRANSLATE_
System::ClearMemorySaveStates();
Host::AddKeyedOSDMessage("TogglePGXPCPU",
g_settings.gpu_pgxp_cpu ?
Host::TranslateStdString("OSDMessage", "PGXP CPU mode is now enabled.") :
Host::TranslateStdString("OSDMessage", "PGXP CPU mode is now disabled."),
TRANSLATE_STR("OSDMessage", "PGXP CPU mode is now enabled.") :
TRANSLATE_STR("OSDMessage", "PGXP CPU mode is now disabled."),
5.0f);
PGXP::Shutdown();
@ -997,25 +994,25 @@ DEFINE_HOTKEY("TogglePGXPCPU", TRANSLATE_NOOP("Hotkeys", "Graphics"), TRANSLATE_
}
})
DEFINE_HOTKEY("AudioMute", TRANSLATE_NOOP("Hotkeys", "Audio"), TRANSLATE_NOOP("Hotkeys", "Toggle Mute"), [](s32 pressed) {
if (!pressed && System::IsValid())
{
g_settings.audio_output_muted = !g_settings.audio_output_muted;
const s32 volume = System::GetAudioOutputVolume();
SPU::GetOutputStream()->SetOutputVolume(volume);
if (g_settings.audio_output_muted)
{
Host::AddIconOSDMessage("AudioControlHotkey", ICON_FA_VOLUME_MUTE,
Host::TranslateStdString("OSDMessage", "Volume: Muted"), 5.0f);
}
else
{
Host::AddIconOSDMessage("AudioControlHotkey", ICON_FA_VOLUME_UP,
fmt::format(Host::TranslateString("OSDMessage", "Volume: {}%").GetCharArray(), volume),
5.0f);
}
}
})
DEFINE_HOTKEY("AudioMute", TRANSLATE_NOOP("Hotkeys", "Audio"), TRANSLATE_NOOP("Hotkeys", "Toggle Mute"),
[](s32 pressed) {
if (!pressed && System::IsValid())
{
g_settings.audio_output_muted = !g_settings.audio_output_muted;
const s32 volume = System::GetAudioOutputVolume();
SPU::GetOutputStream()->SetOutputVolume(volume);
if (g_settings.audio_output_muted)
{
Host::AddIconOSDMessage("AudioControlHotkey", ICON_FA_VOLUME_MUTE,
TRANSLATE_STR("OSDMessage", "Volume: Muted"), 5.0f);
}
else
{
Host::AddIconOSDMessage("AudioControlHotkey", ICON_FA_VOLUME_UP,
fmt::format(TRANSLATE_FS("OSDMessage", "Volume: {}%"), volume), 5.0f);
}
}
})
DEFINE_HOTKEY("AudioCDAudioMute", TRANSLATE_NOOP("Hotkeys", "Audio"), TRANSLATE_NOOP("Hotkeys", "Toggle CD Audio Mute"),
[](s32 pressed) {
if (!pressed && System::IsValid())
@ -1023,25 +1020,25 @@ DEFINE_HOTKEY("AudioCDAudioMute", TRANSLATE_NOOP("Hotkeys", "Audio"), TRANSLATE_
g_settings.cdrom_mute_cd_audio = !g_settings.cdrom_mute_cd_audio;
Host::AddIconOSDMessage(
"AudioControlHotkey", g_settings.cdrom_mute_cd_audio ? ICON_FA_VOLUME_MUTE : ICON_FA_VOLUME_UP,
g_settings.cdrom_mute_cd_audio ? Host::TranslateStdString("OSDMessage", "CD Audio Muted.") :
Host::TranslateStdString("OSDMessage", "CD Audio Unmuted."),
g_settings.cdrom_mute_cd_audio ? TRANSLATE_STR("OSDMessage", "CD Audio Muted.") :
TRANSLATE_STR("OSDMessage", "CD Audio Unmuted."),
2.0f);
}
})
DEFINE_HOTKEY("AudioVolumeUp", TRANSLATE_NOOP("Hotkeys", "Audio"), TRANSLATE_NOOP("Hotkeys", "Volume Up"), [](s32 pressed) {
if (!pressed && System::IsValid())
{
g_settings.audio_output_muted = false;
DEFINE_HOTKEY("AudioVolumeUp", TRANSLATE_NOOP("Hotkeys", "Audio"), TRANSLATE_NOOP("Hotkeys", "Volume Up"),
[](s32 pressed) {
if (!pressed && System::IsValid())
{
g_settings.audio_output_muted = false;
const s32 volume = std::min<s32>(System::GetAudioOutputVolume() + 10, 100);
g_settings.audio_output_volume = volume;
g_settings.audio_fast_forward_volume = volume;
SPU::GetOutputStream()->SetOutputVolume(volume);
Host::AddIconOSDMessage("AudioControlHotkey", ICON_FA_VOLUME_UP,
fmt::format(Host::TranslateString("OSDMessage", "Volume: {}%").GetCharArray(), volume),
5.0f);
}
})
const s32 volume = std::min<s32>(System::GetAudioOutputVolume() + 10, 100);
g_settings.audio_output_volume = volume;
g_settings.audio_fast_forward_volume = volume;
SPU::GetOutputStream()->SetOutputVolume(volume);
Host::AddIconOSDMessage("AudioControlHotkey", ICON_FA_VOLUME_UP,
fmt::format(TRANSLATE_FS("OSDMessage", "Volume: {}%"), volume), 5.0f);
}
})
DEFINE_HOTKEY("AudioVolumeDown", TRANSLATE_NOOP("Hotkeys", "Audio"), TRANSLATE_NOOP("Hotkeys", "Volume Down"),
[](s32 pressed) {
if (!pressed && System::IsValid())
@ -1052,9 +1049,8 @@ DEFINE_HOTKEY("AudioVolumeDown", TRANSLATE_NOOP("Hotkeys", "Audio"), TRANSLATE_N
g_settings.audio_output_volume = volume;
g_settings.audio_fast_forward_volume = volume;
SPU::GetOutputStream()->SetOutputVolume(volume);
Host::AddIconOSDMessage(
"AudioControlHotkey", ICON_FA_VOLUME_DOWN,
fmt::format(Host::TranslateString("OSDMessage", "Volume: {}%").GetCharArray(), volume), 5.0f);
Host::AddIconOSDMessage("AudioControlHotkey", ICON_FA_VOLUME_DOWN,
fmt::format(TRANSLATE_FS("OSDMessage", "Volume: {}%"), volume), 5.0f);
}
})
@ -1087,13 +1083,13 @@ DEFINE_HOTKEY("UndoLoadState", TRANSLATE_NOOP("Hotkeys", "Save States"), TRANSLA
})
#define MAKE_LOAD_STATE_HOTKEY(global, slot, name) \
DEFINE_HOTKEY(global ? "LoadGameState" #slot : "LoadGlobalState" #slot, TRANSLATABLE("Hotkeys", "Save States"), \
DEFINE_HOTKEY(global ? "LoadGameState" #slot : "LoadGlobalState" #slot, TRANSLATE_NOOP("Hotkeys", "Save States"), \
name, [](s32 pressed) { \
if (!pressed) \
Host::RunOnCPUThread([]() { HotkeyLoadStateSlot(global, slot); }); \
})
#define MAKE_SAVE_STATE_HOTKEY(global, slot, name) \
DEFINE_HOTKEY(global ? "SaveGameState" #slot : "SaveGlobalState" #slot, TRANSLATABLE("Hotkeys", "Save States"), \
DEFINE_HOTKEY(global ? "SaveGameState" #slot : "SaveGlobalState" #slot, TRANSLATE_NOOP("Hotkeys", "Save States"), \
name, [](s32 pressed) { \
if (!pressed) \
Host::RunOnCPUThread([]() { HotkeySaveStateSlot(global, slot); }); \

View file

@ -1829,7 +1829,7 @@ bool AddBreakpoint(VirtualMemoryAddress address, bool auto_clear, bool enabled)
if (!auto_clear)
{
Host::ReportFormattedDebuggerMessage(Host::TranslateString("DebuggerMessage", "Added breakpoint at 0x%08X."),
Host::ReportFormattedDebuggerMessage(TRANSLATE("DebuggerMessage", "Added breakpoint at 0x%08X."),
address);
}
@ -1856,7 +1856,7 @@ bool RemoveBreakpoint(VirtualMemoryAddress address)
if (it == s_breakpoints.end())
return false;
Host::ReportFormattedDebuggerMessage(Host::TranslateString("DebuggerMessage", "Removed breakpoint at 0x%08X."),
Host::ReportFormattedDebuggerMessage(TRANSLATE("DebuggerMessage", "Removed breakpoint at 0x%08X."),
address);
s_breakpoints.erase(it);
@ -1888,7 +1888,7 @@ bool AddStepOverBreakpoint()
if (!IsCallInstruction(inst))
{
Host::ReportFormattedDebuggerMessage(Host::TranslateString("DebuggerMessage", "0x%08X is not a call instruction."),
Host::ReportFormattedDebuggerMessage(TRANSLATE("DebuggerMessage", "0x%08X is not a call instruction."),
g_state.pc);
return false;
}
@ -1899,14 +1899,14 @@ bool AddStepOverBreakpoint()
if (IsBranchInstruction(inst))
{
Host::ReportFormattedDebuggerMessage(
Host::TranslateString("DebuggerMessage", "Can't step over double branch at 0x%08X"), g_state.pc);
TRANSLATE("DebuggerMessage", "Can't step over double branch at 0x%08X"), g_state.pc);
return false;
}
// skip the delay slot
bp_pc += sizeof(Instruction);
Host::ReportFormattedDebuggerMessage(Host::TranslateString("DebuggerMessage", "Stepping over to 0x%08X."), bp_pc);
Host::ReportFormattedDebuggerMessage(TRANSLATE("DebuggerMessage", "Stepping over to 0x%08X."), bp_pc);
return AddBreakpoint(bp_pc, true);
}
@ -1923,21 +1923,21 @@ bool AddStepOutBreakpoint(u32 max_instructions_to_search)
if (!SafeReadInstruction(ret_pc, &inst.bits))
{
Host::ReportFormattedDebuggerMessage(
Host::TranslateString("DebuggerMessage", "Instruction read failed at %08X while searching for function end."),
TRANSLATE("DebuggerMessage", "Instruction read failed at %08X while searching for function end."),
ret_pc);
return false;
}
if (IsReturnInstruction(inst))
{
Host::ReportFormattedDebuggerMessage(Host::TranslateString("DebuggerMessage", "Stepping out to 0x%08X."), ret_pc);
Host::ReportFormattedDebuggerMessage(TRANSLATE("DebuggerMessage", "Stepping out to 0x%08X."), ret_pc);
return AddBreakpoint(ret_pc, true);
}
}
Host::ReportFormattedDebuggerMessage(
Host::TranslateString("DebuggerMessage", "No return instruction found after %u instructions for step-out at %08X."),
TRANSLATE("DebuggerMessage", "No return instruction found after %u instructions for step-out at %08X."),
max_instructions_to_search, g_state.pc);
return false;

View file

@ -4510,9 +4510,10 @@ void FullscreenUI::DrawAdvancedSettingsPage()
DrawFloatRangeSetting(bsi, "Display FPS Limit",
"Limits how many frames are displayed to the screen. These frames are still rendered.",
"Display", "MaxFPS", Settings::DEFAULT_DISPLAY_MAX_FPS, 0.0f, 500.0f, "%.2f FPS");
DrawToggleSetting(bsi, "Stretch Display Vertically",
"Stretches the display to match the aspect ratio by multiplying vertically instead of horizontally.",
"Display", "StretchVertically", false);
DrawToggleSetting(
bsi, "Stretch Display Vertically",
"Stretches the display to match the aspect ratio by multiplying vertically instead of horizontally.", "Display",
"StretchVertically", false);
MenuHeading("PGXP Settings");
@ -6955,8 +6956,7 @@ void FullscreenUI::DrawLeaderboardsWindow()
}
else
{
text.Fmt(Host::TranslateString("Achievements", "This game has {} leaderboards.").GetCharArray(),
leaderboard_count);
text.Fmt(TRANSLATE_FS("Achievements", "This game has {} leaderboards."), leaderboard_count);
}
const ImRect summary_bb(ImVec2(left, top), ImVec2(right, top + g_medium_font->FontSize));
@ -6973,8 +6973,8 @@ void FullscreenUI::DrawLeaderboardsWindow()
ImGui::RenderTextClipped(
hardcore_warning_bb.Min, hardcore_warning_bb.Max,
Host::TranslateString(
"Achievements", "Submitting scores is disabled because hardcore mode is off. Leaderboards are read-only."),
TRANSLATE("Achievements",
"Submitting scores is disabled because hardcore mode is off. Leaderboards are read-only."),
nullptr, nullptr, ImVec2(0.0f, 0.0f), &hardcore_warning_bb);
}
@ -7008,8 +7008,8 @@ void FullscreenUI::DrawLeaderboardsWindow()
const ImRect score_bb(ImVec2(text_start_x, bb.Min.y), ImVec2(bb.Max.x, midpoint));
ImGui::RenderTextClipped(score_bb.Min, score_bb.Max,
lboard != nullptr && Achievements::IsLeaderboardTimeType(*lboard) ?
Host::TranslateString("Achievements", "Time") :
Host::TranslateString("Achievements", "Score"),
TRANSLATE("Achievements", "Time") :
TRANSLATE("Achievements", "Score"),
nullptr, nullptr, ImVec2(0.0f, 0.0f), &score_bb);
ImGui::PopFont();
@ -7065,8 +7065,8 @@ void FullscreenUI::DrawLeaderboardsWindow()
const ImVec2 pos_min(0.0f, heading_height);
const ImVec2 pos_max(display_size.x, display_size.y);
ImGui::RenderTextClipped(pos_min, pos_max,
Host::TranslateString("Achievements", "Downloading leaderboard data, please wait..."),
nullptr, nullptr, ImVec2(0.5f, 0.5f));
TRANSLATE("Achievements", "Downloading leaderboard data, please wait..."), nullptr,
nullptr, ImVec2(0.5f, 0.5f));
ImGui::PopFont();
}

View file

@ -228,7 +228,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (display_osd_messages && settings.cpu_execution_mode != CPUExecutionMode::Interpreter)
{
Host::AddKeyedOSDMessage("gamedb_force_interpreter",
Host::TranslateStdString("OSDMessage", "CPU interpreter forced by game settings."),
TRANSLATE_STR("OSDMessage", "CPU interpreter forced by game settings."),
osd_duration);
}
@ -240,7 +240,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (display_osd_messages && settings.gpu_renderer != GPURenderer::Software)
{
Host::AddKeyedOSDMessage("gamedb_force_software",
Host::TranslateStdString("OSDMessage", "Software renderer forced by game settings."),
TRANSLATE_STR("OSDMessage", "Software renderer forced by game settings."),
osd_duration);
}
@ -253,7 +253,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
{
Host::AddKeyedOSDMessage(
"gamedb_force_software_rb",
Host::TranslateStdString("OSDMessage", "Using software renderer for readbacks based on game settings."),
TRANSLATE_STR("OSDMessage", "Using software renderer for readbacks based on game settings."),
osd_duration);
}
@ -265,7 +265,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (display_osd_messages && settings.gpu_disable_interlacing)
{
Host::AddKeyedOSDMessage("gamedb_force_interlacing",
Host::TranslateStdString("OSDMessage", "Interlacing forced by game settings."),
TRANSLATE_STR("OSDMessage", "Interlacing forced by game settings."),
osd_duration);
}
@ -277,7 +277,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (display_osd_messages && settings.gpu_true_color)
{
Host::AddKeyedOSDMessage("gamedb_disable_true_color",
Host::TranslateStdString("OSDMessage", "True color disabled by game settings."),
TRANSLATE_STR("OSDMessage", "True color disabled by game settings."),
osd_duration);
}
@ -289,7 +289,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (display_osd_messages && settings.gpu_resolution_scale > 1)
{
Host::AddKeyedOSDMessage("gamedb_disable_upscaling",
Host::TranslateStdString("OSDMessage", "Upscaling disabled by game settings."),
TRANSLATE_STR("OSDMessage", "Upscaling disabled by game settings."),
osd_duration);
}
@ -301,7 +301,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (display_osd_messages && settings.gpu_scaled_dithering)
{
Host::AddKeyedOSDMessage("gamedb_disable_scaled_dithering",
Host::TranslateStdString("OSDMessage", "Scaled dithering disabled by game settings."),
TRANSLATE_STR("OSDMessage", "Scaled dithering disabled by game settings."),
osd_duration);
}
@ -314,7 +314,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
(settings.display_aspect_ratio == DisplayAspectRatio::R16_9 || settings.gpu_widescreen_hack))
{
Host::AddKeyedOSDMessage("gamedb_disable_widescreen",
Host::TranslateStdString("OSDMessage", "Widescreen disabled by game settings."),
TRANSLATE_STR("OSDMessage", "Widescreen disabled by game settings."),
osd_duration);
}
@ -328,7 +328,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
{
Host::AddKeyedOSDMessage(
"gamedb_disable_force_ntsc_timings",
Host::TranslateStdString("OSDMessage", "Forcing NTSC Timings disallowed by game settings."), osd_duration);
TRANSLATE_STR("OSDMessage", "Forcing NTSC Timings disallowed by game settings."), osd_duration);
}
settings.gpu_force_ntsc_timings = false;
@ -340,7 +340,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
{
Host::AddKeyedOSDMessage(
"gamedb_disable_pgxp",
Host::TranslateStdString("OSDMessage", "PGXP geometry correction disabled by game settings."), osd_duration);
TRANSLATE_STR("OSDMessage", "PGXP geometry correction disabled by game settings."), osd_duration);
}
settings.gpu_pgxp_enable = false;
@ -351,7 +351,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (display_osd_messages && settings.gpu_pgxp_enable && settings.gpu_pgxp_culling)
{
Host::AddKeyedOSDMessage("gamedb_disable_pgxp_culling",
Host::TranslateStdString("OSDMessage", "PGXP culling disabled by game settings."),
TRANSLATE_STR("OSDMessage", "PGXP culling disabled by game settings."),
osd_duration);
}
@ -364,7 +364,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
{
Host::AddKeyedOSDMessage(
"gamedb_disable_pgxp_texture",
Host::TranslateStdString("OSDMessage", "PGXP perspective corrected textures disabled by game settings."),
TRANSLATE_STR("OSDMessage", "PGXP perspective corrected textures disabled by game settings."),
osd_duration);
}
@ -378,7 +378,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
{
Host::AddKeyedOSDMessage(
"gamedb_disable_pgxp_texture",
Host::TranslateStdString("OSDMessage", "PGXP perspective corrected colors disabled by game settings."),
TRANSLATE_STR("OSDMessage", "PGXP perspective corrected colors disabled by game settings."),
osd_duration);
}
@ -390,7 +390,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (display_osd_messages && settings.gpu_pgxp_enable && !settings.gpu_pgxp_vertex_cache)
{
Host::AddKeyedOSDMessage("gamedb_force_pgxp_vertex_cache",
Host::TranslateStdString("OSDMessage", "PGXP vertex cache forced by game settings."),
TRANSLATE_STR("OSDMessage", "PGXP vertex cache forced by game settings."),
osd_duration);
}
@ -402,7 +402,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (display_osd_messages && settings.gpu_pgxp_enable && !settings.gpu_pgxp_cpu)
{
Host::AddKeyedOSDMessage("gamedb_force_pgxp_cpu",
Host::TranslateStdString("OSDMessage", "PGXP CPU mode forced by game settings."),
TRANSLATE_STR("OSDMessage", "PGXP CPU mode forced by game settings."),
osd_duration);
}
@ -414,7 +414,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
if (display_osd_messages && settings.gpu_pgxp_enable && settings.gpu_pgxp_depth_buffer)
{
Host::AddKeyedOSDMessage("gamedb_disable_pgxp_depth",
Host::TranslateStdString("OSDMessage", "PGXP Depth Buffer disabled by game settings."),
TRANSLATE_STR("OSDMessage", "PGXP Depth Buffer disabled by game settings."),
osd_duration);
}
@ -473,15 +473,15 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
supported_controller_string.AppendString(", ");
supported_controller_string.AppendString(
Host::TranslateString("ControllerType", Settings::GetControllerTypeDisplayName(supported_ctype)));
TRANSLATE("ControllerType", Settings::GetControllerTypeDisplayName(supported_ctype)));
}
Host::AddKeyedFormattedOSDMessage(
"gamedb_controller_unsupported", 30.0f,
Host::TranslateString("OSDMessage",
TRANSLATE("OSDMessage",
"Controller in port %u (%s) is not supported for %s.\nSupported controllers: "
"%s\nPlease configure a supported controller from the list above."),
i + 1u, Host::TranslateString("ControllerType", Settings::GetControllerTypeDisplayName(ctype)).GetCharArray(),
i + 1u, TRANSLATE("ControllerType", Settings::GetControllerTypeDisplayName(ctype)),
System::GetGameTitle().c_str(), supported_controller_string.GetCharArray());
}
}

View file

@ -967,7 +967,7 @@ TinyString GameList::FormatTimestamp(std::time_t timestamp)
if (timestamp == 0)
{
ret = Host::TranslateString("GameList", "Never");
ret = TRANSLATE("GameList", "Never");
}
else
{
@ -984,12 +984,12 @@ TinyString GameList::FormatTimestamp(std::time_t timestamp)
if (ctime.tm_year == ttime.tm_year && ctime.tm_yday == ttime.tm_yday)
{
ret = Host::TranslateString("GameList", "Today");
ret = TRANSLATE("GameList", "Today");
}
else if ((ctime.tm_year == ttime.tm_year && ctime.tm_yday == (ttime.tm_yday + 1)) ||
(ctime.tm_yday == 0 && (ctime.tm_year - 1) == ttime.tm_year))
{
ret = Host::TranslateString("GameList", "Yesterday");
ret = TRANSLATE("GameList", "Yesterday");
}
else
{
@ -1012,22 +1012,22 @@ TinyString GameList::FormatTimespan(std::time_t timespan, bool long_format)
if (!long_format)
{
if (hours >= 100)
ret.Fmt(Host::TranslateString("GameList", "{}h {}m").GetCharArray(), hours, minutes);
ret.Fmt(TRANSLATE_FS("GameList", "{}h {}m"), hours, minutes);
else if (hours > 0)
ret.Fmt(Host::TranslateString("GameList", "{}h {}m {}s").GetCharArray(), hours, minutes, seconds);
ret.Fmt(TRANSLATE_FS("GameList", "{}h {}m {}s"), hours, minutes, seconds);
else if (minutes > 0)
ret.Fmt(Host::TranslateString("GameList", "{}m {}s").GetCharArray(), minutes, seconds);
ret.Fmt(TRANSLATE_FS("GameList", "{}m {}s"), minutes, seconds);
else if (seconds > 0)
ret.Fmt(Host::TranslateString("GameList", "{}s").GetCharArray(), seconds);
ret.Fmt(TRANSLATE_FS("GameList", "{}s"), seconds);
else
ret = Host::TranslateString("GameList", "None");
ret = TRANSLATE_SV("GameList", "None");
}
else
{
if (hours > 0)
ret = fmt::format(Host::TranslateString("GameList", "{} hours").GetCharArray(), hours);
ret = fmt::format(TRANSLATE_FS("GameList", "{} hours"), hours);
else
ret = fmt::format(Host::TranslateString("GameList", "{} minutes").GetCharArray(), minutes);
ret = fmt::format(TRANSLATE_FS("GameList", "{} minutes"), minutes);
}
return ret;

View file

@ -51,7 +51,7 @@ bool GPU::Initialize()
if (g_settings.display_post_processing && !g_settings.display_post_process_chain.empty() &&
!g_host_display->SetPostProcessingChain(g_settings.display_post_process_chain))
{
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Failed to load post processing shader chain."), 20.0f);
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Failed to load post processing shader chain."), 20.0f);
}
g_host_display->SetGPUTimingEnabled(g_settings.display_show_gpu);

View file

@ -82,7 +82,7 @@ bool GPU_HW::Initialize()
}
if (!m_per_sample_shading && g_settings.gpu_per_sample_shading)
{
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "SSAA is not supported, using MSAA instead."), 20.0f);
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "SSAA is not supported, using MSAA instead."), 20.0f);
}
if (!m_supports_dual_source_blend && TextureFilterRequiresDualSourceBlend(m_texture_filtering))
{
@ -95,7 +95,7 @@ bool GPU_HW::Initialize()
g_settings.gpu_downsample_mode == GPUDownsampleMode::Adaptive)
{
Host::AddOSDMessage(
Host::TranslateStdString(
TRANSLATE_STR(
"OSDMessage", "Adaptive downsampling is not supported with the current renderer, using box filter instead."),
20.0f);
}
@ -167,7 +167,7 @@ void GPU_HW::UpdateHWSettings(bool* framebuffer_changed, bool* shaders_changed)
{
Host::AddKeyedFormattedOSDMessage(
"ResolutionScale", 10.0f,
Host::TranslateString("OSDMessage", "Resolution scale set to %ux (display %ux%u, VRAM %ux%u)"), resolution_scale,
TRANSLATE("OSDMessage", "Resolution scale set to %ux (display %ux%u, VRAM %ux%u)"), resolution_scale,
m_crtc_state.display_vram_width * resolution_scale, resolution_scale * m_crtc_state.display_vram_height,
VRAM_WIDTH * resolution_scale, VRAM_HEIGHT * resolution_scale);
}
@ -177,13 +177,13 @@ void GPU_HW::UpdateHWSettings(bool* framebuffer_changed, bool* shaders_changed)
if (per_sample_shading)
{
Host::AddKeyedFormattedOSDMessage(
"Multisampling", 10.0f, Host::TranslateString("OSDMessage", "Multisample anti-aliasing set to %ux (SSAA)."),
"Multisampling", 10.0f, TRANSLATE("OSDMessage", "Multisample anti-aliasing set to %ux (SSAA)."),
multisamples);
}
else
{
Host::AddKeyedFormattedOSDMessage("Multisampling", 10.0f,
Host::TranslateString("OSDMessage", "Multisample anti-aliasing set to %ux."),
TRANSLATE("OSDMessage", "Multisample anti-aliasing set to %ux."),
multisamples);
}
}
@ -247,7 +247,7 @@ u32 GPU_HW::CalculateResolutionScale() const
{
Host::AddFormattedOSDMessage(
10.0f,
Host::TranslateString("OSDMessage", "Resolution scale %ux not supported for adaptive smoothing, using %ux."),
TRANSLATE("OSDMessage", "Resolution scale %ux not supported for adaptive smoothing, using %ux."),
scale, new_scale);
}

View file

@ -1320,7 +1320,7 @@ std::unique_ptr<GPU> GPU::CreateHardwareOpenGLRenderer()
(g_host_display->GetRenderAPI() == RenderAPI::OpenGLES && GLAD_GL_ES_VERSION_3_1));
if (!opengl_is_available)
{
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage",
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage",
"OpenGL renderer unavailable, your driver or hardware is not "
"recent enough. OpenGL 3.1 or OpenGL ES 3.1 is required."),
20.0f);

View file

@ -1,9 +1,131 @@
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#include "host.h"
#include "common/assert.h"
#include "common/heterogeneous_containers.h"
#include "common/log.h"
#include "common/string_util.h"
#include <cstdarg>
#include <shared_mutex>
Log_SetChannel(Host);
namespace Host {
static std::pair<const char*, u32> LookupTranslationString(const std::string_view& context,
const std::string_view& msg);
static constexpr u32 TRANSLATION_STRING_CACHE_SIZE = 4 * 1024 * 1024;
using TranslationStringMap = UnorderedStringMap<std::pair<u32, u32>>;
using TranslationStringContextMap = UnorderedStringMap<TranslationStringMap>;
static std::shared_mutex s_translation_string_mutex;
static TranslationStringContextMap s_translation_string_map;
static std::vector<char> s_translation_string_cache;
static u32 s_translation_string_cache_pos;
} // namespace Host
std::pair<const char*, u32> Host::LookupTranslationString(const std::string_view& context, const std::string_view& msg)
{
// TODO: TranslatableString, compile-time hashing.
TranslationStringContextMap::iterator ctx_it;
TranslationStringMap::iterator msg_it;
std::pair<const char*, u32> ret;
s32 len;
// Shouldn't happen, but just in case someone tries to translate an empty string.
if (UNLIKELY(msg.empty()))
{
ret.first = &s_translation_string_cache[0];
ret.second = 0;
return ret;
}
s_translation_string_mutex.lock_shared();
ctx_it = UnorderedStringMapFind(s_translation_string_map, context);
if (UNLIKELY(ctx_it == s_translation_string_map.end()))
goto add_string;
msg_it = UnorderedStringMapFind(ctx_it->second, msg);
if (UNLIKELY(msg_it == ctx_it->second.end()))
goto add_string;
ret.first = &s_translation_string_cache[msg_it->second.first];
ret.second = msg_it->second.second;
s_translation_string_mutex.unlock_shared();
return ret;
add_string:
s_translation_string_mutex.unlock_shared();
s_translation_string_mutex.lock();
if (UNLIKELY(s_translation_string_cache.empty()))
{
// First element is always an empty string.
s_translation_string_cache.resize(TRANSLATION_STRING_CACHE_SIZE);
s_translation_string_cache[0] = '\0';
s_translation_string_cache_pos = 0;
}
if ((len =
Internal::GetTranslatedStringImpl(context, msg, &s_translation_string_cache[s_translation_string_cache_pos],
TRANSLATION_STRING_CACHE_SIZE - 1 - s_translation_string_cache_pos)) < 0)
{
Log_ErrorPrint("WARNING: Clearing translation string cache, it might need to be larger.");
s_translation_string_cache_pos = 0;
if ((len =
Internal::GetTranslatedStringImpl(context, msg, &s_translation_string_cache[s_translation_string_cache_pos],
TRANSLATION_STRING_CACHE_SIZE - 1 - s_translation_string_cache_pos)) < 0)
{
Panic("Failed to get translated string after clearing cache.");
len = 0;
}
}
// New context?
if (ctx_it == s_translation_string_map.end())
ctx_it = s_translation_string_map.emplace(context, TranslationStringMap()).first;
// Impl doesn't null terminate, we need that for C strings.
// TODO: do we want to consider aligning the buffer?
const u32 insert_pos = s_translation_string_cache_pos;
s_translation_string_cache[insert_pos + static_cast<u32>(len)] = 0;
ctx_it->second.emplace(msg, std::pair<u32, u32>(insert_pos, static_cast<u32>(len)));
s_translation_string_cache_pos = insert_pos + static_cast<u32>(len) + 1;
ret.first = &s_translation_string_cache[insert_pos];
ret.second = static_cast<u32>(len);
s_translation_string_mutex.unlock();
return ret;
}
const char* Host::TranslateToCString(const std::string_view& context, const std::string_view& msg)
{
return LookupTranslationString(context, msg).first;
}
std::string_view Host::TranslateToStringView(const std::string_view& context, const std::string_view& msg)
{
const auto mp = LookupTranslationString(context, msg);
return std::string_view(mp.first, mp.second);
}
std::string Host::TranslateToString(const std::string_view& context, const std::string_view& msg)
{
return std::string(TranslateToStringView(context, msg));
}
void Host::ClearTranslationCache()
{
s_translation_string_mutex.lock();
s_translation_string_map.clear();
s_translation_string_cache_pos = 0;
s_translation_string_mutex.unlock();
}
void Host::ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...)
{

View file

@ -20,7 +20,7 @@ enum class AudioStretchMode : u8;
class AudioStream;
class CDImage;
namespace Host {
namespace Host {
/// Typical durations for OSD messages.
static constexpr float OSD_CRITICAL_ERROR_DURATION = 20.0f;
static constexpr float OSD_ERROR_DURATION = 15.0f;
@ -38,10 +38,6 @@ std::optional<std::string> ReadResourceFileToString(const char* filename);
/// Returns the modified time of a resource.
std::optional<std::time_t> GetResourceFileTimestamp(const char* filename);
/// Translates a string to the current language.
TinyString TranslateString(const char* context, const char* str, const char* disambiguation = nullptr, int n = -1);
std::string TranslateStdString(const char* context, const char* str, const char* disambiguation = nullptr, int n = -1);
/// Returns a localized version of the specified string within the specified context.
/// The pointer is guaranteed to be valid until the next language change.
const char* TranslateToCString(const std::string_view& context, const std::string_view& msg);
@ -104,6 +100,12 @@ void OpenURL(const std::string_view& url);
/// Copies the provided text to the host's clipboard, if present.
bool CopyTextToClipboard(const std::string_view& text);
namespace Internal {
/// Implementation to retrieve a translated string.
s32 GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf,
size_t tbuf_space);
} // namespace Internal
} // namespace Host
// Helper macros for retrieving translated strings.

View file

@ -681,13 +681,13 @@ void SaveStateSelectorUI::RefreshHotkeyLegend()
};
s_load_legend = format_legend_entry(Host::GetStringSettingValue("Hotkeys", "LoadSelectedSaveState"),
Host::TranslateStdString("SaveStateSelectorUI", "Load"));
TRANSLATE_STR("SaveStateSelectorUI", "Load"));
s_save_legend = format_legend_entry(Host::GetStringSettingValue("Hotkeys", "SaveSelectedSaveState"),
Host::TranslateStdString("SaveStateSelectorUI", "Save"));
TRANSLATE_STR("SaveStateSelectorUI", "Save"));
s_prev_legend = format_legend_entry(Host::GetStringSettingValue("Hotkeys", "SelectPreviousSaveStateSlot"),
Host::TranslateStdString("SaveStateSelectorUI", "Select Previous"));
TRANSLATE_STR("SaveStateSelectorUI", "Select Previous"));
s_next_legend = format_legend_entry(Host::GetStringSettingValue("Hotkeys", "SelectNextSaveStateSlot"),
Host::TranslateStdString("SaveStateSelectorUI", "Select Next"));
TRANSLATE_STR("SaveStateSelectorUI", "Select Next"));
}
void SaveStateSelectorUI::SelectNextSlot()
@ -744,7 +744,7 @@ void SaveStateSelectorUI::InitializeListEntry(ListEntry* li, ExtendedSaveStateIn
void SaveStateSelectorUI::InitializePlaceholderListEntry(ListEntry* li, std::string path, s32 slot, bool global)
{
li->title = Host::TranslateStdString("SaveStateSelectorUI", "No Save State");
li->title = TRANSLATE_STR("SaveStateSelectorUI", "No Save State");
std::string().swap(li->serial);
li->path = std::move(path);
std::string().swap(li->formatted_timestamp);
@ -817,15 +817,15 @@ void SaveStateSelectorUI::Draw()
if (entry.global)
{
ImGui::Text(Host::TranslateString("SaveStateSelectorUI", "Global Slot %d"), entry.slot);
ImGui::Text(TRANSLATE("SaveStateSelectorUI", "Global Slot %d"), entry.slot);
}
else if (entry.serial.empty())
{
ImGui::Text(Host::TranslateString("SaveStateSelectorUI", "Game Slot %d"), entry.slot);
ImGui::Text(TRANSLATE("SaveStateSelectorUI", "Game Slot %d"), entry.slot);
}
else
{
ImGui::Text(Host::TranslateString("SaveStateSelectorUI", "%s Slot %d"), entry.serial.c_str(), entry.slot);
ImGui::Text(TRANSLATE("SaveStateSelectorUI", "%s Slot %d"), entry.serial.c_str(), entry.slot);
}
ImGui::TextUnformatted(entry.title.c_str());
ImGui::TextUnformatted(entry.formatted_timestamp.c_str());

View file

@ -278,9 +278,8 @@ std::unique_ptr<MemoryCard> MemoryCard::Open(std::string_view filename)
if (!mc->LoadFromFile())
{
Log_InfoPrintf("Memory card at '%s' could not be read, formatting.", mc->m_filename.c_str());
Host::AddFormattedOSDMessage(
5.0f, Host::TranslateString("OSDMessage", "Memory card at '%s' could not be read, formatting."),
mc->m_filename.c_str());
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Memory card at '%s' could not be read, formatting."),
mc->m_filename.c_str());
mc->Format();
}
@ -324,8 +323,7 @@ bool MemoryCard::SaveIfChanged(bool display_osd_message)
{
Host::AddIconOSDMessage(
std::move(osd_key), ICON_FA_SD_CARD,
fmt::format(Host::TranslateString("OSDMessage", "Failed to save memory card to '{}'.").GetCharArray(),
Path::GetFileName(display_name)),
fmt::format(TRANSLATE_FS("OSDMessage", "Failed to save memory card to '{}'."), Path::GetFileName(display_name)),
20.0f);
}
@ -336,9 +334,7 @@ bool MemoryCard::SaveIfChanged(bool display_osd_message)
{
Host::AddIconOSDMessage(
std::move(osd_key), ICON_FA_SD_CARD,
fmt::format(Host::TranslateString("OSDMessage", "Saved memory card to '{}'.").GetCharArray(),
Path::GetFileName(display_name)),
5.0f);
fmt::format(TRANSLATE_FS("OSDMessage", "Saved memory card to '{}'."), Path::GetFileName(display_name)), 5.0f);
}
return true;

View file

@ -193,7 +193,7 @@ bool Pad::DoStateController(StateWrapper& sw, u32 i)
{
Host::AddFormattedOSDMessage(
10.0f,
Host::TranslateString("OSDMessage",
TRANSLATE("OSDMessage",
"Save state contains controller type %s in port %u, but %s is used. Switching."),
Settings::GetControllerTypeName(state_controller_type), i + 1u,
Settings::GetControllerTypeName(controller_type));
@ -201,7 +201,7 @@ bool Pad::DoStateController(StateWrapper& sw, u32 i)
else
{
Host::AddFormattedOSDMessage(
10.0f, Host::TranslateString("OSDMessage", "Ignoring mismatched controller type %s in port %u."),
10.0f, TRANSLATE("OSDMessage", "Ignoring mismatched controller type %s in port %u."),
Settings::GetControllerTypeName(state_controller_type), i + 1u);
}
@ -256,7 +256,7 @@ bool Pad::DoStateMemcard(StateWrapper& sw, u32 i, bool is_memory_state)
{
Host::AddFormattedOSDMessage(
20.0f,
Host::TranslateString("OSDMessage",
TRANSLATE("OSDMessage",
"Memory card %u present in save state but not in system. Creating temporary card."),
i + 1u);
s_memory_cards[i] = MemoryCard::Create();
@ -295,7 +295,7 @@ bool Pad::DoStateMemcard(StateWrapper& sw, u32 i, bool is_memory_state)
{
Host::AddFormattedOSDMessage(
20.0f,
Host::TranslateString("OSDMessage",
TRANSLATE("OSDMessage",
"Memory card %u from save state does match current card data. Simulating replugging."),
i + 1u);
@ -313,7 +313,7 @@ bool Pad::DoStateMemcard(StateWrapper& sw, u32 i, bool is_memory_state)
{
Host::AddFormattedOSDMessage(
20.0f,
Host::TranslateString("OSDMessage", "Memory card %u present in save state but not in system. Ignoring card."),
TRANSLATE("OSDMessage", "Memory card %u present in save state but not in system. Ignoring card."),
i + 1u);
}
@ -326,7 +326,7 @@ bool Pad::DoStateMemcard(StateWrapper& sw, u32 i, bool is_memory_state)
{
Host::AddFormattedOSDMessage(
20.0f,
Host::TranslateString("OSDMessage", "Memory card %u present in system but not in save state. Removing card."),
TRANSLATE("OSDMessage", "Memory card %u present in system but not in save state. Removing card."),
i + 1u);
s_memory_cards[i].reset();
}
@ -334,7 +334,7 @@ bool Pad::DoStateMemcard(StateWrapper& sw, u32 i, bool is_memory_state)
{
Host::AddFormattedOSDMessage(
20.0f,
Host::TranslateString("OSDMessage", "Memory card %u present in system but not in save state. Replugging card."),
TRANSLATE("OSDMessage", "Memory card %u present in system but not in save state. Replugging card."),
i + 1u);
s_memory_cards[i]->Reset();
}

View file

@ -644,7 +644,7 @@ void Settings::FixIncompatibleSettings(bool display_osd_messages)
{
Host::AddKeyedOSDMessage(
"pgxp_disabled_sw",
Host::TranslateStdString("OSDMessage", "PGXP is incompatible with the software renderer, disabling PGXP."),
TRANSLATE_STR("OSDMessage", "PGXP is incompatible with the software renderer, disabling PGXP."),
10.0f);
}
g_settings.gpu_pgxp_enable = false;
@ -664,14 +664,14 @@ void Settings::FixIncompatibleSettings(bool display_osd_messages)
{
Host::AddKeyedOSDMessage(
"rewind_disabled_android",
Host::TranslateStdString("OSDMessage", "Rewind is not supported on 32-bit ARM for Android."), 30.0f);
TRANSLATE_STR("OSDMessage", "Rewind is not supported on 32-bit ARM for Android."), 30.0f);
g_settings.rewind_enable = false;
}
if (g_settings.IsRunaheadEnabled())
{
Host::AddKeyedOSDMessage(
"rewind_disabled_android",
Host::TranslateStdString("OSDMessage", "Runahead is not supported on 32-bit ARM for Android."), 30.0f);
TRANSLATE_STR("OSDMessage", "Runahead is not supported on 32-bit ARM for Android."), 30.0f);
g_settings.runahead_frames = 0;
}
#endif
@ -679,7 +679,7 @@ void Settings::FixIncompatibleSettings(bool display_osd_messages)
if (g_settings.IsRunaheadEnabled() && g_settings.rewind_enable)
{
Host::AddKeyedOSDMessage("rewind_disabled_android",
Host::TranslateStdString("OSDMessage", "Rewind is disabled because runahead is enabled."),
TRANSLATE_STR("OSDMessage", "Rewind is disabled because runahead is enabled."),
10.0f);
g_settings.rewind_enable = false;
}

View file

@ -994,7 +994,7 @@ void System::ResetSystem()
InternalReset();
ResetPerformanceCounters();
ResetThrottler();
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "System reset."));
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "System reset."));
}
void System::PauseSystem(bool paused)
@ -1025,7 +1025,7 @@ bool System::LoadState(const char* filename)
#ifdef WITH_CHEEVOS
if (Achievements::ChallengeModeActive() &&
!Achievements::ConfirmChallengeModeDisable(Host::TranslateString("Achievements", "Loading state")))
!Achievements::ConfirmChallengeModeDisable(TRANSLATE("Achievements", "Loading state")))
{
return false;
}
@ -1043,17 +1043,15 @@ bool System::LoadState(const char* filename)
const std::string display_name(FileSystem::GetDisplayNameFromPath(filename));
Host::AddIconOSDMessage(
"load_state", ICON_FA_FOLDER_OPEN,
fmt::format(Host::TranslateString("OSDMessage", "Loading state from '{}'...").GetCharArray(),
Path::GetFileName(display_name)),
5.0f);
fmt::format(TRANSLATE_FS("OSDMessage", "Loading state from '{}'..."), Path::GetFileName(display_name)), 5.0f);
}
SaveUndoLoadState();
if (!DoLoadState(stream.get(), false, true))
{
Host::ReportFormattedErrorAsync(
"Load State Error", Host::TranslateString("OSDMessage", "Loading state from '%s' failed. Resetting."), filename);
Host::ReportFormattedErrorAsync("Load State Error",
TRANSLATE("OSDMessage", "Loading state from '%s' failed. Resetting."), filename);
if (m_undo_load_state)
UndoLoadState();
@ -1093,17 +1091,16 @@ bool System::SaveState(const char* filename, bool backup_existing_save)
SAVE_STATE_HEADER::COMPRESSION_TYPE_NONE);
if (!result)
{
Host::ReportFormattedErrorAsync(Host::TranslateString("OSDMessage", "Save State"),
Host::TranslateString("OSDMessage", "Saving state to '%s' failed."), filename);
Host::ReportFormattedErrorAsync(TRANSLATE("OSDMessage", "Save State"),
TRANSLATE("OSDMessage", "Saving state to '%s' failed."), filename);
stream->Discard();
}
else
{
const std::string display_name(FileSystem::GetDisplayNameFromPath(filename));
Host::AddIconOSDMessage("save_state", ICON_FA_SAVE,
fmt::format(Host::TranslateString("OSDMessage", "State saved to '{}'.").GetCharArray(),
Path::GetFileName(display_name)),
5.0f);
Host::AddIconOSDMessage(
"save_state", ICON_FA_SAVE,
fmt::format(TRANSLATE_FS("OSDMessage", "State saved to '{}'."), Path::GetFileName(display_name)), 5.0f);
stream->Commit();
}
@ -1247,7 +1244,7 @@ bool System::BootSystem(SystemBootParameters parameters)
#ifdef WITH_CHEEVOS
// Check for resuming with hardcore mode.
if (!parameters.save_state.empty() && Achievements::ChallengeModeActive() &&
!Achievements::ConfirmChallengeModeDisable(Host::TranslateString("Achievements", "Resuming state")))
!Achievements::ConfirmChallengeModeDisable(TRANSLATE("Achievements", "Resuming state")))
{
s_state = State::Shutdown;
ClearRunningGame();
@ -1340,9 +1337,8 @@ bool System::BootSystem(SystemBootParameters parameters)
if (!stream)
{
Host::ReportErrorAsync(
Host::TranslateString("System", "Error"),
fmt::format(Host::TranslateString("System", "Failed to load save state file '{}' for booting.").GetCharArray(),
parameters.save_state));
TRANSLATE("System", "Error"),
fmt::format(TRANSLATE_FS("System", "Failed to load save state file '{}' for booting."), parameters.save_state));
DestroySystem();
return false;
}
@ -1469,15 +1465,14 @@ bool System::Initialize(bool force_software_renderer)
{
Host::AddFormattedOSDMessage(
WARNING_DURATION,
Host::TranslateString("OSDMessage", "CPU clock speed is set to %u%% (%u / %u). This may result in instability."),
TRANSLATE("OSDMessage", "CPU clock speed is set to %u%% (%u / %u). This may result in instability."),
g_settings.GetCPUOverclockPercent(), g_settings.cpu_overclock_numerator, g_settings.cpu_overclock_denominator);
}
if (g_settings.cdrom_read_speedup > 1)
{
Host::AddFormattedOSDMessage(
WARNING_DURATION,
Host::TranslateString("OSDMessage",
"CD-ROM read speedup set to %ux (effective speed %ux). This may result in instability."),
TRANSLATE("OSDMessage", "CD-ROM read speedup set to %ux (effective speed %ux). This may result in instability."),
g_settings.cdrom_read_speedup, g_settings.cdrom_read_speedup * 2);
}
if (g_settings.cdrom_seek_speedup != 1)
@ -1485,14 +1480,13 @@ bool System::Initialize(bool force_software_renderer)
if (g_settings.cdrom_seek_speedup == 0)
{
Host::AddOSDMessage(
Host::TranslateStdString("OSDMessage", "CD-ROM seek speedup set to instant. This may result in instability."),
TRANSLATE_STR("OSDMessage", "CD-ROM seek speedup set to instant. This may result in instability."),
WARNING_DURATION);
}
else
{
Host::AddFormattedOSDMessage(
WARNING_DURATION,
Host::TranslateString("OSDMessage", "CD-ROM seek speedup set to %ux. This may result in instability."),
WARNING_DURATION, TRANSLATE("OSDMessage", "CD-ROM seek speedup set to %ux. This may result in instability."),
g_settings.cdrom_seek_speedup);
}
}
@ -1874,8 +1868,7 @@ bool System::CreateGPU(GPURenderer renderer)
Log_ErrorPrintf("Failed to initialize %s renderer, falling back to software renderer",
Settings::GetRendererName(renderer));
Host::AddFormattedOSDMessage(
30.0f,
Host::TranslateString("OSDMessage", "Failed to initialize %s renderer, falling back to software renderer."),
30.0f, TRANSLATE("OSDMessage", "Failed to initialize %s renderer, falling back to software renderer."),
Settings::GetRendererName(renderer));
g_gpu.reset();
g_gpu = GPU::CreateSoftwareRenderer();
@ -1907,11 +1900,11 @@ bool System::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
{
Log_WarningPrintf("BIOS hash mismatch: System: %s | State: %s", s_bios_hash.ToString().c_str(),
bios_hash.ToString().c_str());
Host::AddKeyedOSDMessage(
"StateBIOSMismatch",
Host::TranslateStdString("OSDMessage", "This save state was created with a different BIOS version or patch "
"options. This may cause stability issues."),
10.0f);
Host::AddKeyedOSDMessage("StateBIOSMismatch",
TRANSLATE_STR("OSDMessage",
"This save state was created with a different BIOS version or patch "
"options. This may cause stability issues."),
10.0f);
}
}
@ -1982,7 +1975,7 @@ bool System::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
g_settings.cpu_overclock_denominator != cpu_overclock_denominator))))
{
Host::AddFormattedOSDMessage(
10.0f, Host::TranslateString("OSDMessage", "WARNING: CPU overclock (%u%%) was different in save state (%u%%)."),
10.0f, TRANSLATE("OSDMessage", "WARNING: CPU overclock (%u%%) was different in save state (%u%%)."),
g_settings.cpu_overclock_enable ? g_settings.GetCPUOverclockPercent() : 100u,
cpu_overclock_active ?
Settings::CPUOverclockFractionToPercent(cpu_overclock_numerator, cpu_overclock_denominator) :
@ -2025,14 +2018,14 @@ bool System::LoadBIOS()
std::optional<BIOS::Image> bios_image(BIOS::GetBIOSImage(s_region));
if (!bios_image.has_value())
{
Host::ReportFormattedErrorAsync("Error", Host::TranslateString("System", "Failed to load %s BIOS."),
Host::ReportFormattedErrorAsync("Error", TRANSLATE("System", "Failed to load %s BIOS."),
Settings::GetConsoleRegionName(s_region));
return false;
}
if (bios_image->size() != static_cast<u32>(Bus::BIOS_SIZE))
{
Host::ReportFormattedErrorAsync("Error", Host::TranslateString("System", "Incorrect BIOS image size"));
Host::ReportFormattedErrorAsync("Error", TRANSLATE("System", "Incorrect BIOS image size"));
return false;
}
@ -2122,8 +2115,7 @@ bool System::DoLoadState(ByteStream* state, bool force_software_renderer, bool u
if (header.version < SAVE_STATE_MINIMUM_VERSION)
{
Host::ReportFormattedErrorAsync(
"Error",
Host::TranslateString("System", "Save state is incompatible: minimum version is %u but state is version %u."),
"Error", TRANSLATE("System", "Save state is incompatible: minimum version is %u but state is version %u."),
SAVE_STATE_MINIMUM_VERSION, header.version);
return false;
}
@ -2131,8 +2123,7 @@ bool System::DoLoadState(ByteStream* state, bool force_software_renderer, bool u
if (header.version > SAVE_STATE_VERSION)
{
Host::ReportFormattedErrorAsync(
"Error",
Host::TranslateString("System", "Save state is incompatible: maximum version is %u but state is version %u."),
"Error", TRANSLATE("System", "Save state is incompatible: maximum version is %u but state is version %u."),
SAVE_STATE_VERSION, header.version);
return false;
}
@ -2164,17 +2155,17 @@ bool System::DoLoadState(ByteStream* state, bool force_software_renderer, bool u
{
Host::AddFormattedOSDMessage(
30.0f,
Host::TranslateString("OSDMessage", "Failed to open CD image from save state '%s': %s. Using "
"existing image '%s', this may result in instability."),
TRANSLATE("OSDMessage", "Failed to open CD image from save state '%s': %s. Using "
"existing image '%s', this may result in instability."),
media_filename.c_str(), error.GetDescription().c_str(), old_media->GetFileName().c_str());
media = std::move(old_media);
header.media_subimage_index = media->GetCurrentSubImage();
}
else
{
Host::ReportFormattedErrorAsync(
"Error", Host::TranslateString("System", "Failed to open CD image '%s' used by save state: %s."),
media_filename.c_str(), error.GetDescription().c_str());
Host::ReportFormattedErrorAsync("Error",
TRANSLATE("System", "Failed to open CD image '%s' used by save state: %s."),
media_filename.c_str(), error.GetDescription().c_str());
return false;
}
}
@ -2191,8 +2182,7 @@ bool System::DoLoadState(ByteStream* state, bool force_software_renderer, bool u
!media->SwitchSubImage(header.media_subimage_index, &error)))
{
Host::ReportFormattedErrorAsync(
"Error",
Host::TranslateString("System", "Failed to switch to subimage %u in CD image '%s' used by save state: %s."),
"Error", TRANSLATE("System", "Failed to switch to subimage %u in CD image '%s' used by save state: %s."),
header.media_subimage_index + 1u, media_filename.c_str(), error.GetDescription().c_str());
return false;
}
@ -2226,8 +2216,7 @@ bool System::DoLoadState(ByteStream* state, bool force_software_renderer, bool u
if (Achievements::ChallengeModeActive())
{
Host::AddKeyedOSDMessage("challenge_mode_reset",
Host::TranslateStdString("Achievements", "Hardcore mode disabled by state switch."),
10.0f);
TRANSLATE_STR("Achievements", "Hardcore mode disabled by state switch."), 10.0f);
Achievements::DisableChallengeMode();
}
#endif
@ -2586,8 +2575,7 @@ void System::SetRewindState(bool enabled)
if (!g_settings.rewind_enable)
{
if (enabled)
Host::AddKeyedOSDMessage("SetRewindState", Host::TranslateStdString("OSDMessage", "Rewinding is not enabled."),
5.0f);
Host::AddKeyedOSDMessage("SetRewindState", TRANSLATE_STR("OSDMessage", "Rewinding is not enabled."), 5.0f);
return;
}
@ -2628,7 +2616,7 @@ void System::DoToggleCheats()
CheatList* cl = GetCheatList();
if (!cl)
{
Host::AddKeyedOSDMessage("ToggleCheats", Host::TranslateStdString("OSDMessage", "No cheats are loaded."), 10.0f);
Host::AddKeyedOSDMessage("ToggleCheats", TRANSLATE_STR("OSDMessage", "No cheats are loaded."), 10.0f);
return;
}
@ -2636,8 +2624,8 @@ void System::DoToggleCheats()
Host::AddKeyedOSDMessage(
"ToggleCheats",
cl->GetMasterEnable() ?
Host::TranslateStdString("OSDMessage", "%n cheats are now active.", "", cl->GetEnabledCodeCount()) :
Host::TranslateStdString("OSDMessage", "%n cheats are now inactive.", "", cl->GetEnabledCodeCount()),
fmt::format(TRANSLATE_FS("OSDMessage", "{} cheats are now active."), cl->GetEnabledCodeCount()) :
fmt::format(TRANSLATE_FS("OSDMessage", "{} cheats are now inactive."), cl->GetEnabledCodeCount()),
10.0f);
}
@ -2871,11 +2859,11 @@ std::unique_ptr<MemoryCard> System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp
{
if (s_running_game_serial.empty())
{
Host::AddFormattedOSDMessage(
5.0f,
Host::TranslateString("System", "Per-game memory card cannot be used for slot %u as the running "
"game has no code. Using shared card instead."),
slot + 1u);
Host::AddFormattedOSDMessage(5.0f,
TRANSLATE("System",
"Per-game memory card cannot be used for slot %u as the running "
"game has no code. Using shared card instead."),
slot + 1u);
return MemoryCard::Open(g_settings.GetSharedMemoryCardPath(slot));
}
else
@ -2888,11 +2876,11 @@ std::unique_ptr<MemoryCard> System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp
{
if (s_running_game_title.empty())
{
Host::AddFormattedOSDMessage(
5.0f,
Host::TranslateString("System", "Per-game memory card cannot be used for slot %u as the running "
"game has no title. Using shared card instead."),
slot + 1u);
Host::AddFormattedOSDMessage(5.0f,
TRANSLATE("System",
"Per-game memory card cannot be used for slot %u as the running "
"game has no title. Using shared card instead."),
slot + 1u);
return MemoryCard::Open(g_settings.GetSharedMemoryCardPath(slot));
}
else
@ -2908,11 +2896,11 @@ std::unique_ptr<MemoryCard> System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp
const std::string_view file_title(Path::GetFileTitle(display_name));
if (file_title.empty())
{
Host::AddFormattedOSDMessage(
5.0f,
Host::TranslateString("System", "Per-game memory card cannot be used for slot %u as the running "
"game has no path. Using shared card instead."),
slot + 1u);
Host::AddFormattedOSDMessage(5.0f,
TRANSLATE("System",
"Per-game memory card cannot be used for slot %u as the running "
"game has no path. Using shared card instead."),
slot + 1u);
return MemoryCard::Open(g_settings.GetSharedMemoryCardPath(slot));
}
else
@ -2982,25 +2970,23 @@ void System::SwapMemoryCards()
if (HasMemoryCard(0) && HasMemoryCard(1))
{
Host::AddOSDMessage(
Host::TranslateStdString("OSDMessage", "Swapped memory card ports. Both ports have a memory card."), 10.0f);
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Swapped memory card ports. Both ports have a memory card."),
10.0f);
}
else if (HasMemoryCard(1))
{
Host::AddOSDMessage(
Host::TranslateStdString("OSDMessage", "Swapped memory card ports. Port 2 has a memory card, Port 1 is empty."),
10.0f);
TRANSLATE_STR("OSDMessage", "Swapped memory card ports. Port 2 has a memory card, Port 1 is empty."), 10.0f);
}
else if (HasMemoryCard(0))
{
Host::AddOSDMessage(
Host::TranslateStdString("OSDMessage", "Swapped memory card ports. Port 1 has a memory card, Port 2 is empty."),
10.0f);
TRANSLATE_STR("OSDMessage", "Swapped memory card ports. Port 1 has a memory card, Port 2 is empty."), 10.0f);
}
else
{
Host::AddOSDMessage(
Host::TranslateStdString("OSDMessage", "Swapped memory card ports. Neither port has a memory card."), 10.0f);
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Swapped memory card ports. Neither port has a memory card."),
10.0f);
}
}
@ -3085,8 +3071,8 @@ bool System::InsertMedia(const char* path)
std::unique_ptr<CDImage> image = CDImage::Open(path, g_settings.cdrom_load_image_patches, &error);
if (!image)
{
Host::AddFormattedOSDMessage(10.0f, Host::TranslateString("OSDMessage", "Failed to open disc image '%s': %s."),
path, error.GetDescription().c_str());
Host::AddFormattedOSDMessage(10.0f, TRANSLATE("OSDMessage", "Failed to open disc image '%s': %s."), path,
error.GetDescription().c_str());
return false;
}
@ -3098,12 +3084,12 @@ bool System::InsertMedia(const char* path)
if (g_settings.cdrom_load_image_to_ram)
CDROM::PrecacheMedia();
Host::AddFormattedOSDMessage(10.0f, Host::TranslateString("OSDMessage", "Inserted disc '%s' (%s)."),
s_running_game_title.c_str(), s_running_game_serial.c_str());
Host::AddFormattedOSDMessage(10.0f, TRANSLATE("OSDMessage", "Inserted disc '%s' (%s)."), s_running_game_title.c_str(),
s_running_game_serial.c_str());
if (g_settings.HasAnyPerGameMemoryCards())
{
Host::AddOSDMessage(Host::TranslateStdString("System", "Game changed, reloading memory cards."), 10.0f);
Host::AddOSDMessage(TRANSLATE_STR("System", "Game changed, reloading memory cards."), 10.0f);
UpdatePerGameMemoryCards();
}
@ -3198,7 +3184,7 @@ bool System::CheckForSBIFile(CDImage* image)
return Host::ConfirmMessage(
"Confirm Unsupported Configuration",
StringUtil::StdStringFromFormat(
Host::TranslateString(
TRANSLATE(
"System",
"You are attempting to run a libcrypt protected game without an SBI file:\n\n%s: %s\n\nThe game will "
"likely not run properly.\n\nPlease check the README for instructions on how to add an SBI file.\n\nDo "
@ -3209,13 +3195,12 @@ bool System::CheckForSBIFile(CDImage* image)
else
{
Host::ReportErrorAsync(
Host::TranslateString("System", "Error"),
TRANSLATE("System", "Error"),
SmallString::FromFormat(
Host::TranslateString(
"System",
"You are attempting to run a libcrypt protected game without an SBI file:\n\n%s: %s\n\nYour dump is "
"incomplete, you must add the SBI file to run this game. \n\n"
"The name of the SBI file must match the name of the disc image."),
TRANSLATE("System",
"You are attempting to run a libcrypt protected game without an SBI file:\n\n%s: %s\n\nYour dump is "
"incomplete, you must add the SBI file to run this game. \n\n"
"The name of the SBI file must match the name of the disc image."),
s_running_game_serial.c_str(), s_running_game_title.c_str()));
return false;
}
@ -3275,8 +3260,7 @@ bool System::SwitchMediaSubImage(u32 index)
Error error;
if (!image->SwitchSubImage(index, &error))
{
Host::AddFormattedOSDMessage(10.0f,
Host::TranslateString("OSDMessage", "Failed to switch to subimage %u in '%s': %s."),
Host::AddFormattedOSDMessage(10.0f, TRANSLATE("OSDMessage", "Failed to switch to subimage %u in '%s': %s."),
index + 1u, image->GetFileName().c_str(), error.GetDescription().c_str());
const DiscRegion region = GetRegionForImage(image.get());
@ -3284,7 +3268,7 @@ bool System::SwitchMediaSubImage(u32 index)
return false;
}
Host::AddFormattedOSDMessage(20.0f, Host::TranslateString("OSDMessage", "Switched to sub-image %s (%u) in '%s'."),
Host::AddFormattedOSDMessage(20.0f, TRANSLATE("OSDMessage", "Switched to sub-image %s (%u) in '%s'."),
image->GetSubImageMetadata(index, "title").c_str(), index + 1u,
image->GetMetadata("title").c_str());
const DiscRegion region = GetRegionForImage(image.get());
@ -3326,7 +3310,7 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
const bool recreate_display = (g_settings.gpu_use_debug_device != old_settings.gpu_use_debug_device ||
g_settings.gpu_threaded_presentation != old_settings.gpu_threaded_presentation);
Host::AddFormattedOSDMessage(5.0f, Host::TranslateString("OSDMessage", "Switching to %s%s GPU renderer."),
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Switching to %s%s GPU renderer."),
Settings::GetRendererName(g_settings.gpu_renderer),
g_settings.gpu_use_debug_device ? " (debug)" : "");
RecreateGPU(g_settings.gpu_renderer, recreate_display);
@ -3350,7 +3334,7 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
{
if (g_settings.audio_backend != old_settings.audio_backend)
{
Host::AddFormattedOSDMessage(5.0f, Host::TranslateString("OSDMessage", "Switching to %s audio backend."),
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Switching to %s audio backend."),
Settings::GetAudioBackendName(g_settings.audio_backend));
}
@ -3372,10 +3356,10 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
if (g_settings.cpu_execution_mode != old_settings.cpu_execution_mode ||
g_settings.cpu_fastmem_mode != old_settings.cpu_fastmem_mode)
{
Host::AddFormattedOSDMessage(5.0f, Host::TranslateString("OSDMessage", "Switching to %s CPU execution mode."),
Host::TranslateString("CPUExecutionMode", Settings::GetCPUExecutionModeDisplayName(
g_settings.cpu_execution_mode))
.GetCharArray());
Host::AddOSDMessage(fmt::format(TRANSLATE_FS("OSDMessage", "Switching to {} CPU execution mode."),
TRANSLATE_SV("CPUExecutionMode", Settings::GetCPUExecutionModeDisplayName(
g_settings.cpu_execution_mode))),
5.0f);
CPU::CodeCache::Reinitialize();
CPU::ClearICache();
}
@ -3385,8 +3369,7 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
g_settings.cpu_recompiler_block_linking != old_settings.cpu_recompiler_block_linking ||
g_settings.cpu_recompiler_icache != old_settings.cpu_recompiler_icache))
{
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Recompiler options changed, flushing all blocks."),
5.0f);
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Recompiler options changed, flushing all blocks."), 5.0f);
// changing memory exceptions can re-enable fastmem
if (g_settings.cpu_recompiler_memory_exceptions != old_settings.cpu_recompiler_memory_exceptions)
@ -3450,8 +3433,8 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
if (g_settings.IsUsingCodeCache())
{
Host::AddOSDMessage(g_settings.gpu_pgxp_enable ?
Host::TranslateStdString("OSDMessage", "PGXP enabled, recompiling all blocks.") :
Host::TranslateStdString("OSDMessage", "PGXP disabled, recompiling all blocks."),
TRANSLATE_STR("OSDMessage", "PGXP enabled, recompiling all blocks.") :
TRANSLATE_STR("OSDMessage", "PGXP disabled, recompiling all blocks."),
5.0f);
CPU::CodeCache::Flush();
}
@ -3510,8 +3493,7 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
if (g_settings.display_post_processing && !g_settings.display_post_process_chain.empty())
{
if (!g_host_display->SetPostProcessingChain(g_settings.display_post_process_chain))
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Failed to load post processing shader chain."),
20.0f);
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Failed to load post processing shader chain."), 20.0f);
}
else
{
@ -3897,7 +3879,7 @@ bool System::SaveUndoLoadState()
m_undo_load_state = ByteStream::CreateGrowableMemoryStream(nullptr, System::MAX_SAVE_STATE_SIZE);
if (!InternalSaveState(m_undo_load_state.get()))
{
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Failed to save undo load state."), 15.0f);
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Failed to save undo load state."), 15.0f);
m_undo_load_state.reset();
return false;
}
@ -3958,13 +3940,12 @@ bool System::StartDumpingAudio(const char* filename)
if (SPU::StartDumpingAudio(filename))
{
Host::AddFormattedOSDMessage(5.0f, Host::TranslateString("OSDMessage", "Started dumping audio to '%s'."), filename);
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Started dumping audio to '%s'."), filename);
return true;
}
else
{
Host::AddFormattedOSDMessage(10.0f, Host::TranslateString("OSDMessage", "Failed to start dumping audio to '%s'."),
filename);
Host::AddFormattedOSDMessage(10.0f, TRANSLATE("OSDMessage", "Failed to start dumping audio to '%s'."), filename);
return false;
}
}
@ -3974,7 +3955,7 @@ void System::StopDumpingAudio()
if (System::IsShutdown() || !SPU::StopDumpingAudio())
return;
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Stopped dumping audio."), 5.0f);
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Stopped dumping audio."), 5.0f);
}
bool System::SaveScreenshot(const char* filename /* = nullptr */, bool full_resolution /* = true */,
@ -4004,8 +3985,7 @@ bool System::SaveScreenshot(const char* filename /* = nullptr */, bool full_reso
if (FileSystem::FileExists(filename))
{
Host::AddFormattedOSDMessage(10.0f, Host::TranslateString("OSDMessage", "Screenshot file '%s' already exists."),
filename);
Host::AddFormattedOSDMessage(10.0f, TRANSLATE("OSDMessage", "Screenshot file '%s' already exists."), filename);
return false;
}
@ -4014,12 +3994,11 @@ bool System::SaveScreenshot(const char* filename /* = nullptr */, bool full_reso
if (!screenshot_saved)
{
Host::AddFormattedOSDMessage(10.0f, Host::TranslateString("OSDMessage", "Failed to save screenshot to '%s'"),
filename);
Host::AddFormattedOSDMessage(10.0f, TRANSLATE("OSDMessage", "Failed to save screenshot to '%s'"), filename);
return false;
}
Host::AddFormattedOSDMessage(5.0f, Host::TranslateString("OSDMessage", "Screenshot saved to '%s'."), filename);
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Screenshot saved to '%s'."), filename);
return true;
}
@ -4104,7 +4083,7 @@ std::optional<ExtendedSaveStateInfo> System::InternalGetExtendedSaveStateInfo(By
if (header.version < SAVE_STATE_MINIMUM_VERSION || header.version > SAVE_STATE_VERSION)
{
ssi.title = StringUtil::StdStringFromFormat(
Host::TranslateString("CommonHostInterface", "Invalid version %u (%s version %u)"), header.version,
TRANSLATE("CommonHostInterface", "Invalid version %u (%s version %u)"), header.version,
header.version > SAVE_STATE_VERSION ? "maximum" : "minimum",
header.version > SAVE_STATE_VERSION ? SAVE_STATE_VERSION : SAVE_STATE_MINIMUM_VERSION);
return ssi;
@ -4195,16 +4174,16 @@ bool System::LoadCheatList(const char* filename)
std::unique_ptr<CheatList> cl = std::make_unique<CheatList>();
if (!cl->LoadFromFile(filename, CheatList::Format::Autodetect))
{
Host::AddFormattedOSDMessage(15.0f, Host::TranslateString("OSDMessage", "Failed to load cheats from '%s'."),
filename);
Host::AddFormattedOSDMessage(15.0f, TRANSLATE("OSDMessage", "Failed to load cheats from '%s'."), filename);
return false;
}
if (cl->GetEnabledCodeCount() > 0)
{
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "%n cheats are enabled. This may result in instability.",
"", cl->GetEnabledCodeCount()),
30.0f);
Host::AddOSDMessage(
fmt::format(TRANSLATE_FS("OSDMessage", "{} cheats are enabled. This may result in instability."),
cl->GetEnabledCodeCount()),
30.0f);
}
System::SetCheatList(std::move(cl));
@ -4249,8 +4228,7 @@ bool System::SaveCheatList()
if (!System::GetCheatList()->SaveToPCSXRFile(filename.c_str()))
{
Host::AddFormattedOSDMessage(15.0f, Host::TranslateString("OSDMessage", "Failed to save cheat list to '%s'"),
filename.c_str());
Host::AddFormattedOSDMessage(15.0f, TRANSLATE("OSDMessage", "Failed to save cheat list to '%s'"), filename.c_str());
}
return true;
@ -4266,8 +4244,7 @@ bool System::SaveCheatList(const char* filename)
// This shouldn't be needed, but lupdate doesn't gather this string otherwise...
const u32 code_count = System::GetCheatList()->GetCodeCount();
Host::AddFormattedOSDMessage(5.0f, Host::TranslateString("OSDMessage", "Saved %n cheats to '%s'.", "", code_count),
filename);
Host::AddOSDMessage(fmt::format(TRANSLATE_FS("OSDMessage", "Saved {} cheats to '{}'."), code_count, filename), 5.0f);
return true;
}
@ -4282,8 +4259,7 @@ bool System::DeleteCheatList()
if (!FileSystem::DeleteFile(filename.c_str()))
return false;
Host::AddFormattedOSDMessage(5.0f, Host::TranslateString("OSDMessage", "Deleted cheat list '%s'."),
filename.c_str());
Host::AddOSDMessage(fmt::format(TRANSLATE_FS("OSDMessage", "Deleted cheat list '{}'."), filename), 5.0f);
}
System::SetCheatList(nullptr);
@ -4325,13 +4301,11 @@ void System::SetCheatCodeState(u32 index, bool enabled, bool save_to_file)
if (enabled)
{
Host::AddFormattedOSDMessage(5.0f, Host::TranslateString("OSDMessage", "Cheat '%s' enabled."),
cc.description.c_str());
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Cheat '%s' enabled."), cc.description.c_str());
}
else
{
Host::AddFormattedOSDMessage(5.0f, Host::TranslateString("OSDMessage", "Cheat '%s' disabled."),
cc.description.c_str());
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Cheat '%s' disabled."), cc.description.c_str());
}
if (save_to_file)
@ -4347,12 +4321,11 @@ void System::ApplyCheatCode(u32 index)
if (!cc.enabled)
{
cc.Apply();
Host::AddFormattedOSDMessage(5.0f, Host::TranslateString("OSDMessage", "Applied cheat '%s'."),
cc.description.c_str());
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Applied cheat '%s'."), cc.description.c_str());
}
else
{
Host::AddFormattedOSDMessage(5.0f, Host::TranslateString("OSDMessage", "Cheat '%s' is already enabled."),
Host::AddFormattedOSDMessage(5.0f, TRANSLATE("OSDMessage", "Cheat '%s' is already enabled."),
cc.description.c_str());
}
}
@ -4365,17 +4338,14 @@ void System::TogglePostProcessing()
g_settings.display_post_processing = !g_settings.display_post_processing;
if (g_settings.display_post_processing)
{
Host::AddKeyedOSDMessage("PostProcessing",
Host::TranslateStdString("OSDMessage", "Post-processing is now enabled."), 10.0f);
Host::AddKeyedOSDMessage("PostProcessing", TRANSLATE_STR("OSDMessage", "Post-processing is now enabled."), 10.0f);
if (!g_host_display->SetPostProcessingChain(g_settings.display_post_process_chain))
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Failed to load post processing shader chain."),
20.0f);
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Failed to load post processing shader chain."), 20.0f);
}
else
{
Host::AddKeyedOSDMessage("PostProcessing",
Host::TranslateStdString("OSDMessage", "Post-processing is now disabled."), 10.0f);
Host::AddKeyedOSDMessage("PostProcessing", TRANSLATE_STR("OSDMessage", "Post-processing is now disabled."), 10.0f);
g_host_display->SetPostProcessingChain({});
}
}
@ -4386,9 +4356,9 @@ void System::ReloadPostProcessingShaders()
return;
if (!g_host_display->SetPostProcessingChain(g_settings.display_post_process_chain))
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Failed to load post-processing shader chain."), 20.0f);
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Failed to load post-processing shader chain."), 20.0f);
else
Host::AddOSDMessage(Host::TranslateStdString("OSDMessage", "Post-processing shaders reloaded."), 10.0f);
Host::AddOSDMessage(TRANSLATE_STR("OSDMessage", "Post-processing shaders reloaded."), 10.0f);
}
void System::ToggleWidescreen()
@ -4415,19 +4385,20 @@ void System::ToggleWidescreen()
if (g_settings.gpu_widescreen_hack)
{
Host::AddKeyedFormattedOSDMessage(
"WidescreenHack", 5.0f,
Host::TranslateString("OSDMessage", "Widescreen hack is now enabled, and aspect ratio is set to %s."),
Host::TranslateString("DisplayAspectRatio", Settings::GetDisplayAspectRatioName(g_settings.display_aspect_ratio))
.GetCharArray());
Host::AddKeyedOSDMessage(
"WidescreenHack",
fmt::format(
TRANSLATE_FS("OSDMessage", "Widescreen hack is now enabled, and aspect ratio is set to {}."),
TRANSLATE("DisplayAspectRatio", Settings::GetDisplayAspectRatioName(g_settings.display_aspect_ratio))),
5.0f);
}
else
{
Host::AddKeyedFormattedOSDMessage(
"WidescreenHack", 5.0f,
Host::TranslateString("OSDMessage", "Widescreen hack is now disabled, and aspect ratio is set to %s."),
Host::TranslateString("DisplayAspectRatio", Settings::GetDisplayAspectRatioName(g_settings.display_aspect_ratio))
.GetCharArray());
Host::AddKeyedOSDMessage(
"WidescreenHack",
fmt::format(TRANSLATE_FS("OSDMessage", "Widescreen hack is now disabled, and aspect ratio is set to {}."),
TRANSLATE("DisplayAspectRatio", Settings::GetDisplayAspectRatioName(g_settings.display_aspect_ratio)),
5.0f));
}
GTE::UpdateAspectRatio();
@ -4440,8 +4411,7 @@ void System::ToggleSoftwareRendering()
const GPURenderer new_renderer = g_gpu->IsHardwareRenderer() ? GPURenderer::Software : g_settings.gpu_renderer;
Host::AddKeyedFormattedOSDMessage("SoftwareRendering", 5.0f,
Host::TranslateString("OSDMessage", "Switching to %s renderer..."),
Host::AddKeyedFormattedOSDMessage("SoftwareRendering", 5.0f, TRANSLATE("OSDMessage", "Switching to %s renderer..."),
Settings::GetRendererDisplayName(new_renderer));
RecreateGPU(new_renderer);
Host::InvalidateDisplay();

View file

@ -338,14 +338,16 @@ void Host::OnInputDeviceDisconnected(const std::string_view& identifier)
fmt::format("Input device {} disconnected.", identifier), 10.0f);
}
TinyString Host::TranslateString(const char* context, const char* str, const char* disambiguation, int n)
s32 Host::Internal::GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf,
size_t tbuf_space)
{
return str;
}
if (msg.size() > tbuf_space)
return -1;
else if (msg.empty())
return 0;
std::string Host::TranslateStdString(const char* context, const char* str, const char* disambiguation, int n)
{
return str;
std::memcpy(tbuf, msg.data(), msg.size());
return static_cast<s32>(msg.size());
}
std::optional<std::vector<u8>> Host::ReadResourceFile(const char* filename)

View file

@ -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);
}
}

View file

@ -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())

View file

@ -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)

View file

@ -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.

View file

@ -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

View file

@ -142,14 +142,16 @@ void Host::ReportDebuggerMessage(const std::string_view& message)
Log_ErrorPrintf("ReportDebuggerMessage: %.*s", static_cast<int>(message.size()), message.data());
}
TinyString Host::TranslateString(const char* context, const char* str, const char* disambiguation, int n)
s32 Host::Internal::GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf,
size_t tbuf_space)
{
return str;
}
if (msg.size() > tbuf_space)
return -1;
else if (msg.empty())
return 0;
std::string Host::TranslateStdString(const char* context, const char* str, const char* disambiguation, int n)
{
return str;
std::memcpy(tbuf, msg.data(), msg.size());
return static_cast<s32>(msg.size());
}
void Host::LoadSettings(SettingsInterface& si, std::unique_lock<std::mutex>& lock)

View file

@ -253,7 +253,7 @@ std::vector<std::string> AudioStream::GetCubebDriverNames()
std::vector<std::pair<std::string, std::string>> AudioStream::GetCubebOutputDevices(const char* driver)
{
std::vector<std::pair<std::string, std::string>> ret;
ret.emplace_back(std::string(), Host::TranslateStdString("CommonHost", "Default Output Device"));
ret.emplace_back(std::string(), TRANSLATE_STR("CommonHost", "Default Output Device"));
cubeb* context;
int rv = cubeb_init(&context, "DuckStation", (driver && *driver) ? driver : nullptr);