Host: Add disambiguation variants for translations

This commit is contained in:
Stenzek 2024-09-03 21:39:00 +10:00
parent 9e67a7f3cc
commit 2840262f28
No known key found for this signature in database
13 changed files with 324 additions and 243 deletions

View file

@ -54,14 +54,24 @@ static bool ParseYamlCodes(u32 index, const ryml::ConstNodeRef& value, std::stri
static bool LoadTrackHashes(); static bool LoadTrackHashes();
static constexpr const std::array<const char*, static_cast<int>(CompatibilityRating::Count)> static constexpr const std::array<const char*, static_cast<int>(CompatibilityRating::Count)>
s_compatibility_rating_names = { s_compatibility_rating_names = {{
{"Unknown", "DoesntBoot", "CrashesInIntro", "CrashesInGame", "GraphicalAudioIssues", "NoIssues"}}; "Unknown",
"DoesntBoot",
"CrashesInIntro",
"CrashesInGame",
"GraphicalAudioIssues",
"NoIssues",
}};
static constexpr const std::array<const char*, static_cast<size_t>(CompatibilityRating::Count)> static constexpr const std::array<const char*, static_cast<size_t>(CompatibilityRating::Count)>
s_compatibility_rating_display_names = { s_compatibility_rating_display_names = {{
{TRANSLATE_NOOP("GameDatabase", "Unknown"), TRANSLATE_NOOP("GameDatabase", "Doesn't Boot"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Unknown", "CompatibilityRating"),
TRANSLATE_NOOP("GameDatabase", "Crashes In Intro"), TRANSLATE_NOOP("GameDatabase", "Crashes In-Game"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Doesn't Boot", "CompatibilityRating"),
TRANSLATE_NOOP("GameDatabase", "Graphical/Audio Issues"), TRANSLATE_NOOP("GameDatabase", "No Issues")}}; TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Crashes In Intro", "CompatibilityRating"),
TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Crashes In-Game", "CompatibilityRating"),
TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Graphical/Audio Issues", "CompatibilityRating"),
TRANSLATE_DISAMBIG_NOOP("GameDatabase", "No Issues", "CompatibilityRating"),
}};
static constexpr const std::array<const char*, static_cast<u32>(GameDatabase::Trait::Count)> s_trait_names = {{ static constexpr const std::array<const char*, static_cast<u32>(GameDatabase::Trait::Count)> s_trait_names = {{
"ForceInterpreter", "ForceInterpreter",
@ -93,32 +103,32 @@ static constexpr const std::array<const char*, static_cast<u32>(GameDatabase::Tr
}}; }};
static constexpr const std::array<const char*, static_cast<u32>(GameDatabase::Trait::Count)> s_trait_display_names = {{ static constexpr const std::array<const char*, static_cast<u32>(GameDatabase::Trait::Count)> s_trait_display_names = {{
TRANSLATE_NOOP("GameDatabase", "Force Interpreter"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force Interpreter", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Force Software Renderer"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force Software Renderer", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Force Software Renderer For Readbacks"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force Software Renderer For Readbacks", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Force Round Texture Coordinates"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force Round Texture Coordinates", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Force Accurate Blending"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force Accurate Blending", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Force Interlacing"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force Interlacing", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable Automatic Analog Mode"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable Automatic Analog Mode", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable True Color"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable True Color", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable Upscaling"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable Upscaling", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable Texture Filtering"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable Texture Filtering", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable Sprite Texture Filtering"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable Sprite Texture Filtering", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable Scaled Dithering"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable Scaled Dithering", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable Widescreen"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable Widescreen", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable PGXP"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable PGXP", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable PGXP Culling"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable PGXP Culling", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable PGXP Texture Correction"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable PGXP Texture Correction", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable PGXP Color Correction"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable PGXP Color Correction", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable PGXP Depth Buffer"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable PGXP Depth Buffer", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable PGXP Preserve Projection Floating Point"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable PGXP Preserve Projection Floating Point", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Disable PGXP on 2D Polygons"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Disable PGXP on 2D Polygons", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Force PGXP Vertex Cache"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force PGXP Vertex Cache", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Force PGXP CPU Mode"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force PGXP CPU Mode", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Force Recompiler Memory Exceptions"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force Recompiler Memory Exceptions", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Force Recompiler ICache"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force Recompiler ICache", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Force Recompiler LUT Fastmem"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Force Recompiler LUT Fastmem", "GameDatabase::Trait"),
TRANSLATE_NOOP("GameDatabase", "Is LibCrypt Protected"), TRANSLATE_DISAMBIG_NOOP("GameDatabase", "Is LibCrypt Protected", "GameDatabase::Trait"),
}}; }};
static constexpr const char* GAMEDB_YAML_FILENAME = "gamedb.yaml"; static constexpr const char* GAMEDB_YAML_FILENAME = "gamedb.yaml";

View file

@ -131,17 +131,26 @@ static bool s_game_list_loaded = false;
const char* GameList::GetEntryTypeName(EntryType type) const char* GameList::GetEntryTypeName(EntryType type)
{ {
static std::array<const char*, static_cast<int>(EntryType::Count)> names = { static std::array<const char*, static_cast<int>(EntryType::Count)> names = {{
{"Disc", "DiscSet", "PSExe", "Playlist", "PSF"}}; "Disc",
return names[static_cast<int>(type)]; "DiscSet",
"PSExe",
"Playlist",
"PSF",
}};
return names[static_cast<size_t>(type)];
} }
const char* GameList::GetEntryTypeDisplayName(EntryType type) const char* GameList::GetEntryTypeDisplayName(EntryType type)
{ {
static std::array<const char*, static_cast<int>(EntryType::Count)> names = { static std::array<const char*, static_cast<int>(EntryType::Count)> names = {{
{TRANSLATE_NOOP("GameList", "Disc"), TRANSLATE_NOOP("GameList", "Disc Set"), TRANSLATE_NOOP("GameList", "PS-EXE"), TRANSLATE_DISAMBIG_NOOP("GameList", "Disc", "EntryType"),
TRANSLATE_NOOP("GameList", "Playlist"), TRANSLATE_NOOP("GameList", "PSF")}}; TRANSLATE_DISAMBIG_NOOP("GameList", "Disc Set", "EntryType"),
return Host::TranslateToCString("GameList", names[static_cast<int>(type)]); TRANSLATE_DISAMBIG_NOOP("GameList", "PS-EXE", "EntryType"),
TRANSLATE_DISAMBIG_NOOP("GameList", "Playlist", "EntryType"),
TRANSLATE_DISAMBIG_NOOP("GameList", "PSF", "EntryType"),
}};
return Host::TranslateToCString("GameList", names[static_cast<size_t>(type)], "EntryType");
} }
bool GameList::IsGameListLoaded() bool GameList::IsGameListLoaded()
@ -831,7 +840,8 @@ GameList::EntryList GameList::TakeEntryList()
return ret; return ret;
} }
void GameList::CreateDiscSetEntries(const std::vector<std::string>& excluded_paths, const PlayedTimeMap& played_time_map) void GameList::CreateDiscSetEntries(const std::vector<std::string>& excluded_paths,
const PlayedTimeMap& played_time_map)
{ {
std::unique_lock lock(s_mutex); std::unique_lock lock(s_mutex);

View file

@ -909,10 +909,14 @@ static constexpr const std::array s_log_level_names = {
"None", "Error", "Warning", "Info", "Verbose", "Dev", "Debug", "Trace", "None", "Error", "Warning", "Info", "Verbose", "Dev", "Debug", "Trace",
}; };
static constexpr const std::array s_log_level_display_names = { static constexpr const std::array s_log_level_display_names = {
TRANSLATE_NOOP("LogLevel", "None"), TRANSLATE_NOOP("LogLevel", "Error"), TRANSLATE_DISAMBIG_NOOP("Settings", "None", "LogLevel"),
TRANSLATE_NOOP("LogLevel", "Warning"), TRANSLATE_NOOP("LogLevel", "Information"), TRANSLATE_DISAMBIG_NOOP("Settings", "Error", "LogLevel"),
TRANSLATE_NOOP("LogLevel", "Verbose"), TRANSLATE_NOOP("LogLevel", "Developer"), TRANSLATE_DISAMBIG_NOOP("Settings", "Warning", "LogLevel"),
TRANSLATE_NOOP("LogLevel", "Debug"), TRANSLATE_NOOP("LogLevel", "Trace"), TRANSLATE_DISAMBIG_NOOP("Settings", "Information", "LogLevel"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Verbose", "LogLevel"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Developer", "LogLevel"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Debug", "LogLevel"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Trace", "LogLevel"),
}; };
std::optional<LOGLEVEL> Settings::ParseLogLevelName(const char* str) std::optional<LOGLEVEL> Settings::ParseLogLevelName(const char* str)
@ -936,13 +940,21 @@ const char* Settings::GetLogLevelName(LOGLEVEL level)
const char* Settings::GetLogLevelDisplayName(LOGLEVEL level) const char* Settings::GetLogLevelDisplayName(LOGLEVEL level)
{ {
return Host::TranslateToCString("LogLevel", s_log_level_display_names[static_cast<size_t>(level)]); return Host::TranslateToCString("Settings", s_log_level_display_names[static_cast<size_t>(level)], "LogLevel");
} }
static constexpr const std::array s_console_region_names = {"Auto", "NTSC-J", "NTSC-U", "PAL"}; static constexpr const std::array s_console_region_names = {
"Auto",
"NTSC-J",
"NTSC-U",
"PAL",
};
static constexpr const std::array s_console_region_display_names = { static constexpr const std::array s_console_region_display_names = {
TRANSLATE_NOOP("ConsoleRegion", "Auto-Detect"), TRANSLATE_NOOP("ConsoleRegion", "NTSC-J (Japan)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Auto-Detect", "ConsoleRegion"),
TRANSLATE_NOOP("ConsoleRegion", "NTSC-U/C (US, Canada)"), TRANSLATE_NOOP("ConsoleRegion", "PAL (Europe, Australia)")}; TRANSLATE_DISAMBIG_NOOP("Settings", "NTSC-J (Japan)", "ConsoleRegion"),
TRANSLATE_DISAMBIG_NOOP("Settings", "NTSC-U/C (US, Canada)", "ConsoleRegion"),
TRANSLATE_DISAMBIG_NOOP("Settings", "PAL (Europe, Australia)", "ConsoleRegion"),
};
std::optional<ConsoleRegion> Settings::ParseConsoleRegionName(const char* str) std::optional<ConsoleRegion> Settings::ParseConsoleRegionName(const char* str)
{ {
@ -965,14 +977,20 @@ const char* Settings::GetConsoleRegionName(ConsoleRegion region)
const char* Settings::GetConsoleRegionDisplayName(ConsoleRegion region) const char* Settings::GetConsoleRegionDisplayName(ConsoleRegion region)
{ {
return Host::TranslateToCString("ConsoleRegion", s_console_region_display_names[static_cast<size_t>(region)]); return Host::TranslateToCString("Settings", s_console_region_display_names[static_cast<size_t>(region)],
"ConsoleRegion");
} }
static constexpr const std::array s_disc_region_names = {"NTSC-J", "NTSC-U", "PAL", "Other", "Non-PS1"}; static constexpr const std::array s_disc_region_names = {
"NTSC-J", "NTSC-U", "PAL", "Other", "Non-PS1",
};
static constexpr const std::array s_disc_region_display_names = { static constexpr const std::array s_disc_region_display_names = {
TRANSLATE_NOOP("DiscRegion", "NTSC-J (Japan)"), TRANSLATE_NOOP("DiscRegion", "NTSC-U/C (US, Canada)"), TRANSLATE_DISAMBIG_NOOP("Settings", "NTSC-J (Japan)", "DiscRegion"),
TRANSLATE_NOOP("DiscRegion", "PAL (Europe, Australia)"), TRANSLATE_NOOP("DiscRegion", "Other"), TRANSLATE_DISAMBIG_NOOP("Settings", "NTSC-U/C (US, Canada)", "DiscRegion"),
TRANSLATE_NOOP("DiscRegion", "Non-PS1")}; TRANSLATE_DISAMBIG_NOOP("Settings", "PAL (Europe, Australia)", "DiscRegion"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Other", "DiscRegion"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Non-PS1", "DiscRegion"),
};
std::optional<DiscRegion> Settings::ParseDiscRegionName(const char* str) std::optional<DiscRegion> Settings::ParseDiscRegionName(const char* str)
{ {
@ -995,16 +1013,21 @@ const char* Settings::GetDiscRegionName(DiscRegion region)
const char* Settings::GetDiscRegionDisplayName(DiscRegion region) const char* Settings::GetDiscRegionDisplayName(DiscRegion region)
{ {
return Host::TranslateToCString("DiscRegion", s_disc_region_display_names[static_cast<size_t>(region)]); return Host::TranslateToCString("Settings", s_disc_region_display_names[static_cast<size_t>(region)], "DiscRegion");
} }
static constexpr const std::array s_cpu_execution_mode_names = {"Interpreter", "CachedInterpreter", "Recompiler", static constexpr const std::array s_cpu_execution_mode_names = {
"NewRec"}; "Interpreter",
"CachedInterpreter",
"Recompiler",
"NewRec",
};
static constexpr const std::array s_cpu_execution_mode_display_names = { static constexpr const std::array s_cpu_execution_mode_display_names = {
TRANSLATE_NOOP("CPUExecutionMode", "Interpreter (Slowest)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Interpreter (Slowest)", "CPUExecutionMode"),
TRANSLATE_NOOP("CPUExecutionMode", "Cached Interpreter (Faster)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Cached Interpreter (Faster)", "CPUExecutionMode"),
TRANSLATE_NOOP("CPUExecutionMode", "Recompiler (Fastest)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Recompiler (Fastest)", "CPUExecutionMode"),
TRANSLATE_NOOP("CPUExecutionMode", "New Recompiler (Experimental)")}; TRANSLATE_DISAMBIG_NOOP("Settings", "New Recompiler (Experimental)", "CPUExecutionMode"),
};
std::optional<CPUExecutionMode> Settings::ParseCPUExecutionMode(const char* str) std::optional<CPUExecutionMode> Settings::ParseCPUExecutionMode(const char* str)
{ {
@ -1027,14 +1050,20 @@ const char* Settings::GetCPUExecutionModeName(CPUExecutionMode mode)
const char* Settings::GetCPUExecutionModeDisplayName(CPUExecutionMode mode) const char* Settings::GetCPUExecutionModeDisplayName(CPUExecutionMode mode)
{ {
return Host::TranslateToCString("CPUExecutionMode", s_cpu_execution_mode_display_names[static_cast<u8>(mode)]); return Host::TranslateToCString("Settings", s_cpu_execution_mode_display_names[static_cast<size_t>(mode)],
"CPUExecutionMode");
} }
static constexpr const std::array s_cpu_fastmem_mode_names = {"Disabled", "MMap", "LUT"}; static constexpr const std::array s_cpu_fastmem_mode_names = {
"Disabled",
"MMap",
"LUT",
};
static constexpr const std::array s_cpu_fastmem_mode_display_names = { static constexpr const std::array s_cpu_fastmem_mode_display_names = {
TRANSLATE_NOOP("CPUFastmemMode", "Disabled (Slowest)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Disabled (Slowest)", "CPUFastmemMode"),
TRANSLATE_NOOP("CPUFastmemMode", "MMap (Hardware, Fastest, 64-Bit Only)"), TRANSLATE_DISAMBIG_NOOP("Settings", "MMap (Hardware, Fastest, 64-Bit Only)", "CPUFastmemMode"),
TRANSLATE_NOOP("CPUFastmemMode", "LUT (Faster)")}; TRANSLATE_DISAMBIG_NOOP("Settings", "LUT (Faster)", "CPUFastmemMode"),
};
std::optional<CPUFastmemMode> Settings::ParseCPUFastmemMode(const char* str) std::optional<CPUFastmemMode> Settings::ParseCPUFastmemMode(const char* str)
{ {
@ -1057,7 +1086,8 @@ const char* Settings::GetCPUFastmemModeName(CPUFastmemMode mode)
const char* Settings::GetCPUFastmemModeDisplayName(CPUFastmemMode mode) const char* Settings::GetCPUFastmemModeDisplayName(CPUFastmemMode mode)
{ {
return Host::TranslateToCString("CPUFastmemMode", s_cpu_fastmem_mode_display_names[static_cast<u8>(mode)]); return Host::TranslateToCString("Settings", s_cpu_fastmem_mode_display_names[static_cast<size_t>(mode)],
"CPUFastmemMode");
} }
static constexpr const std::array s_gpu_renderer_names = { static constexpr const std::array s_gpu_renderer_names = {
@ -1077,20 +1107,21 @@ static constexpr const std::array s_gpu_renderer_names = {
"Software", "Software",
}; };
static constexpr const std::array s_gpu_renderer_display_names = { static constexpr const std::array s_gpu_renderer_display_names = {
TRANSLATE_NOOP("GPURenderer", "Automatic"), TRANSLATE_DISAMBIG_NOOP("Settings", "Automatic", "GPURenderer"),
#ifdef _WIN32 #ifdef _WIN32
TRANSLATE_NOOP("GPURenderer", "Direct3D 11"), TRANSLATE_NOOP("GPURenderer", "Direct3D 12"), TRANSLATE_DISAMBIG_NOOP("Settings", "Direct3D 11", "GPURenderer"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Direct3D 12", "GPURenderer"),
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
TRANSLATE_NOOP("GPURenderer", "Metal"), TRANSLATE_DISAMBIG_NOOP("Settings", "Metal", "GPURenderer"),
#endif #endif
#ifdef ENABLE_VULKAN #ifdef ENABLE_VULKAN
TRANSLATE_NOOP("GPURenderer", "Vulkan"), TRANSLATE_DISAMBIG_NOOP("Settings", "Vulkan", "GPURenderer"),
#endif #endif
#ifdef ENABLE_OPENGL #ifdef ENABLE_OPENGL
TRANSLATE_NOOP("GPURenderer", "OpenGL"), TRANSLATE_DISAMBIG_NOOP("Settings", "OpenGL", "GPURenderer"),
#endif #endif
TRANSLATE_NOOP("GPURenderer", "Software"), TRANSLATE_DISAMBIG_NOOP("Settings", "Software", "GPURenderer"),
}; };
std::optional<GPURenderer> Settings::ParseRendererName(const char* str) std::optional<GPURenderer> Settings::ParseRendererName(const char* str)
@ -1114,7 +1145,8 @@ const char* Settings::GetRendererName(GPURenderer renderer)
const char* Settings::GetRendererDisplayName(GPURenderer renderer) const char* Settings::GetRendererDisplayName(GPURenderer renderer)
{ {
return Host::TranslateToCString("GPURenderer", s_gpu_renderer_display_names[static_cast<size_t>(renderer)]); return Host::TranslateToCString("Settings", s_gpu_renderer_display_names[static_cast<size_t>(renderer)],
"GPURenderer");
} }
RenderAPI Settings::GetRenderAPIForRenderer(GPURenderer renderer) RenderAPI Settings::GetRenderAPIForRenderer(GPURenderer renderer)
@ -1187,13 +1219,13 @@ static constexpr const std::array s_texture_filter_names = {
"Nearest", "Bilinear", "BilinearBinAlpha", "JINC2", "JINC2BinAlpha", "xBR", "xBRBinAlpha", "Nearest", "Bilinear", "BilinearBinAlpha", "JINC2", "JINC2BinAlpha", "xBR", "xBRBinAlpha",
}; };
static constexpr const std::array s_texture_filter_display_names = { static constexpr const std::array s_texture_filter_display_names = {
TRANSLATE_NOOP("GPUTextureFilter", "Nearest-Neighbor"), TRANSLATE_DISAMBIG_NOOP("Settings", "Nearest-Neighbor", "GPUTextureFilter"),
TRANSLATE_NOOP("GPUTextureFilter", "Bilinear"), TRANSLATE_DISAMBIG_NOOP("Settings", "Bilinear", "GPUTextureFilter"),
TRANSLATE_NOOP("GPUTextureFilter", "Bilinear (No Edge Blending)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Bilinear (No Edge Blending)", "GPUTextureFilter"),
TRANSLATE_NOOP("GPUTextureFilter", "JINC2 (Slow)"), TRANSLATE_DISAMBIG_NOOP("Settings", "JINC2 (Slow)", "GPUTextureFilter"),
TRANSLATE_NOOP("GPUTextureFilter", "JINC2 (Slow, No Edge Blending)"), TRANSLATE_DISAMBIG_NOOP("Settings", "JINC2 (Slow, No Edge Blending)", "GPUTextureFilter"),
TRANSLATE_NOOP("GPUTextureFilter", "xBR (Very Slow)"), TRANSLATE_DISAMBIG_NOOP("Settings", "xBR (Very Slow)", "GPUTextureFilter"),
TRANSLATE_NOOP("GPUTextureFilter", "xBR (Very Slow, No Edge Blending)"), TRANSLATE_DISAMBIG_NOOP("Settings", "xBR (Very Slow, No Edge Blending)", "GPUTextureFilter"),
}; };
std::optional<GPUTextureFilter> Settings::ParseTextureFilterName(const char* str) std::optional<GPUTextureFilter> Settings::ParseTextureFilterName(const char* str)
@ -1217,7 +1249,8 @@ const char* Settings::GetTextureFilterName(GPUTextureFilter filter)
const char* Settings::GetTextureFilterDisplayName(GPUTextureFilter filter) const char* Settings::GetTextureFilterDisplayName(GPUTextureFilter filter)
{ {
return Host::TranslateToCString("GPUTextureFilter", s_texture_filter_display_names[static_cast<size_t>(filter)]); return Host::TranslateToCString("Settings", s_texture_filter_display_names[static_cast<size_t>(filter)],
"GPUTextureFilter");
} }
static constexpr const std::array s_line_detect_mode_names = { static constexpr const std::array s_line_detect_mode_names = {
@ -1227,10 +1260,10 @@ static constexpr const std::array s_line_detect_mode_names = {
"AggressiveTriangles", "AggressiveTriangles",
}; };
static constexpr const std::array s_line_detect_mode_detect_names = { static constexpr const std::array s_line_detect_mode_detect_names = {
TRANSLATE_NOOP("GPULineDetectMode", "Disabled"), TRANSLATE_DISAMBIG_NOOP("Settings", "Disabled", "GPULineDetectMode"),
TRANSLATE_NOOP("GPULineDetectMode", "Quads"), TRANSLATE_DISAMBIG_NOOP("Settings", "Quads", "GPULineDetectMode"),
TRANSLATE_NOOP("GPULineDetectMode", "Triangles (Basic)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Triangles (Basic)", "GPULineDetectMode"),
TRANSLATE_NOOP("GPULineDetectMode", "Triangles (Aggressive)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Triangles (Aggressive)", "GPULineDetectMode"),
}; };
std::optional<GPULineDetectMode> Settings::ParseLineDetectModeName(const char* str) std::optional<GPULineDetectMode> Settings::ParseLineDetectModeName(const char* str)
@ -1254,14 +1287,15 @@ const char* Settings::GetLineDetectModeName(GPULineDetectMode mode)
const char* Settings::GetLineDetectModeDisplayName(GPULineDetectMode mode) const char* Settings::GetLineDetectModeDisplayName(GPULineDetectMode mode)
{ {
return Host::TranslateToCString("GPULineDetectMode", s_line_detect_mode_detect_names[static_cast<size_t>(mode)]); return Host::TranslateToCString("Settings", s_line_detect_mode_detect_names[static_cast<size_t>(mode)],
"GPULineDetectMode");
} }
static constexpr const std::array s_downsample_mode_names = {"Disabled", "Box", "Adaptive"}; static constexpr const std::array s_downsample_mode_names = {"Disabled", "Box", "Adaptive"};
static constexpr const std::array s_downsample_mode_display_names = { static constexpr const std::array s_downsample_mode_display_names = {
TRANSLATE_NOOP("GPUDownsampleMode", "Disabled"), TRANSLATE_DISAMBIG_NOOP("Settings", "Disabled", "GPUDownsampleMode"),
TRANSLATE_NOOP("GPUDownsampleMode", "Box (Downsample 3D/Smooth All)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Box (Downsample 3D/Smooth All)", "GPUDownsampleMode"),
TRANSLATE_NOOP("GPUDownsampleMode", "Adaptive (Preserve 3D/Smooth 2D)")}; TRANSLATE_DISAMBIG_NOOP("Settings", "Adaptive (Preserve 3D/Smooth 2D)", "GPUDownsampleMode")};
std::optional<GPUDownsampleMode> Settings::ParseDownsampleModeName(const char* str) std::optional<GPUDownsampleMode> Settings::ParseDownsampleModeName(const char* str)
{ {
@ -1284,13 +1318,15 @@ const char* Settings::GetDownsampleModeName(GPUDownsampleMode mode)
const char* Settings::GetDownsampleModeDisplayName(GPUDownsampleMode mode) const char* Settings::GetDownsampleModeDisplayName(GPUDownsampleMode mode)
{ {
return Host::TranslateToCString("GPUDownsampleMode", s_downsample_mode_display_names[static_cast<size_t>(mode)]); return Host::TranslateToCString("Settings", s_downsample_mode_display_names[static_cast<size_t>(mode)],
"GPUDownsampleMode");
} }
static constexpr const std::array s_wireframe_mode_names = {"Disabled", "OverlayWireframe", "OnlyWireframe"}; static constexpr const std::array s_wireframe_mode_names = {"Disabled", "OverlayWireframe", "OnlyWireframe"};
static constexpr const std::array s_wireframe_mode_display_names = { static constexpr const std::array s_wireframe_mode_display_names = {
TRANSLATE_NOOP("GPUWireframeMode", "Disabled"), TRANSLATE_NOOP("GPUWireframeMode", "Overlay Wireframe"), TRANSLATE_DISAMBIG_NOOP("Settings", "Disabled", "GPUWireframeMode"),
TRANSLATE_NOOP("GPUWireframeMode", "Only Wireframe")}; TRANSLATE_DISAMBIG_NOOP("Settings", "Overlay Wireframe", "GPUWireframeMode"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Only Wireframe", "GPUWireframeMode")};
std::optional<GPUWireframeMode> Settings::ParseGPUWireframeMode(const char* str) std::optional<GPUWireframeMode> Settings::ParseGPUWireframeMode(const char* str)
{ {
@ -1313,22 +1349,19 @@ const char* Settings::GetGPUWireframeModeName(GPUWireframeMode mode)
const char* Settings::GetGPUWireframeModeDisplayName(GPUWireframeMode mode) const char* Settings::GetGPUWireframeModeDisplayName(GPUWireframeMode mode)
{ {
return Host::TranslateToCString("GPUWireframeMode", s_wireframe_mode_display_names[static_cast<size_t>(mode)]); return Host::TranslateToCString("Settings", s_wireframe_mode_display_names[static_cast<size_t>(mode)],
"GPUWireframeMode");
} }
static constexpr const std::array s_display_deinterlacing_mode_names = { static constexpr const std::array s_display_deinterlacing_mode_names = {
"Disabled", "Disabled", "Weave", "Blend", "Adaptive", "Progressive",
"Weave",
"Blend",
"Adaptive",
"Progressive",
}; };
static constexpr const std::array s_display_deinterlacing_mode_display_names = { static constexpr const std::array s_display_deinterlacing_mode_display_names = {
TRANSLATE_NOOP("DisplayDeinterlacingMode", "Disabled (Flickering)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Disabled (Flickering)", "DisplayDeinterlacingMode"),
TRANSLATE_NOOP("DisplayDeinterlacingMode", "Weave (Combing)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Weave (Combing)", "DisplayDeinterlacingMode"),
TRANSLATE_NOOP("DisplayDeinterlacingMode", "Blend (Blur)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Blend (Blur)", "DisplayDeinterlacingMode"),
TRANSLATE_NOOP("DisplayDeinterlacingMode", "Adaptive (FastMAD)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Adaptive (FastMAD)", "DisplayDeinterlacingMode"),
TRANSLATE_NOOP("DisplayDeinterlacingMode", "Progressive (Optimal)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Progressive (Optimal)", "DisplayDeinterlacingMode"),
}; };
std::optional<DisplayDeinterlacingMode> Settings::ParseDisplayDeinterlacingMode(const char* str) std::optional<DisplayDeinterlacingMode> Settings::ParseDisplayDeinterlacingMode(const char* str)
@ -1352,14 +1385,16 @@ const char* Settings::GetDisplayDeinterlacingModeName(DisplayDeinterlacingMode m
const char* Settings::GetDisplayDeinterlacingModeDisplayName(DisplayDeinterlacingMode mode) const char* Settings::GetDisplayDeinterlacingModeDisplayName(DisplayDeinterlacingMode mode)
{ {
return Host::TranslateToCString("DisplayDeinterlacingMode", return Host::TranslateToCString("Settings", s_display_deinterlacing_mode_display_names[static_cast<size_t>(mode)],
s_display_deinterlacing_mode_display_names[static_cast<size_t>(mode)]); "DisplayDeinterlacingMode");
} }
static constexpr const std::array s_display_crop_mode_names = {"None", "Overscan", "Borders"}; static constexpr const std::array s_display_crop_mode_names = {"None", "Overscan", "Borders"};
static constexpr const std::array s_display_crop_mode_display_names = { static constexpr const std::array s_display_crop_mode_display_names = {
TRANSLATE_NOOP("DisplayCropMode", "None"), TRANSLATE_NOOP("DisplayCropMode", "Only Overscan Area"), TRANSLATE_DISAMBIG_NOOP("Settings", "None", "DisplayCropMode"),
TRANSLATE_NOOP("DisplayCropMode", "All Borders")}; TRANSLATE_DISAMBIG_NOOP("Settings", "Only Overscan Area", "DisplayCropMode"),
TRANSLATE_DISAMBIG_NOOP("Settings", "All Borders", "DisplayCropMode"),
};
std::optional<DisplayCropMode> Settings::ParseDisplayCropMode(const char* str) std::optional<DisplayCropMode> Settings::ParseDisplayCropMode(const char* str)
{ {
@ -1382,14 +1417,15 @@ const char* Settings::GetDisplayCropModeName(DisplayCropMode crop_mode)
const char* Settings::GetDisplayCropModeDisplayName(DisplayCropMode crop_mode) const char* Settings::GetDisplayCropModeDisplayName(DisplayCropMode crop_mode)
{ {
return Host::TranslateToCString("DisplayCropMode", s_display_crop_mode_display_names[static_cast<size_t>(crop_mode)]); return Host::TranslateToCString("Settings", s_display_crop_mode_display_names[static_cast<size_t>(crop_mode)],
"DisplayCropMode");
} }
static constexpr const std::array s_display_aspect_ratio_names = { static constexpr const std::array s_display_aspect_ratio_names = {
#ifndef __ANDROID__ #ifndef __ANDROID__
TRANSLATE_NOOP("DisplayAspectRatio", "Auto (Game Native)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Auto (Game Native)", "DisplayAspectRatio"),
TRANSLATE_NOOP("DisplayAspectRatio", "Stretch To Fill"), TRANSLATE_DISAMBIG_NOOP("Settings", "Stretch To Fill", "DisplayAspectRatio"),
TRANSLATE_NOOP("DisplayAspectRatio", "Custom"), TRANSLATE_DISAMBIG_NOOP("Settings", "Custom", "DisplayAspectRatio"),
#else #else
"Auto (Game Native)", "Auto (Game Native)",
"Auto (Match Window)", "Auto (Match Window)",
@ -1424,7 +1460,8 @@ const char* Settings::GetDisplayAspectRatioName(DisplayAspectRatio ar)
const char* Settings::GetDisplayAspectRatioDisplayName(DisplayAspectRatio ar) const char* Settings::GetDisplayAspectRatioDisplayName(DisplayAspectRatio ar)
{ {
return Host::TranslateToCString("DisplayAspectRatio", s_display_aspect_ratio_names[static_cast<size_t>(ar)]); return Host::TranslateToCString("Settings", s_display_aspect_ratio_names[static_cast<size_t>(ar)],
"DisplayAspectRatio");
} }
float Settings::GetDisplayAspectRatioValue() const float Settings::GetDisplayAspectRatioValue() const
@ -1454,8 +1491,10 @@ float Settings::GetDisplayAspectRatioValue() const
static constexpr const std::array s_display_alignment_names = {"LeftOrTop", "Center", "RightOrBottom"}; static constexpr const std::array s_display_alignment_names = {"LeftOrTop", "Center", "RightOrBottom"};
static constexpr const std::array s_display_alignment_display_names = { static constexpr const std::array s_display_alignment_display_names = {
TRANSLATE_NOOP("DisplayAlignment", "Left / Top"), TRANSLATE_NOOP("DisplayAlignment", "Center"), TRANSLATE_DISAMBIG_NOOP("Settings", "Left / Top", "DisplayAlignment"),
TRANSLATE_NOOP("DisplayAlignment", "Right / Bottom")}; TRANSLATE_DISAMBIG_NOOP("Settings", "Center", "DisplayAlignment"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Right / Bottom", "DisplayAlignment"),
};
std::optional<DisplayAlignment> Settings::ParseDisplayAlignment(const char* str) std::optional<DisplayAlignment> Settings::ParseDisplayAlignment(const char* str)
{ {
@ -1478,16 +1517,16 @@ const char* Settings::GetDisplayAlignmentName(DisplayAlignment alignment)
const char* Settings::GetDisplayAlignmentDisplayName(DisplayAlignment alignment) const char* Settings::GetDisplayAlignmentDisplayName(DisplayAlignment alignment)
{ {
return Host::TranslateToCString("DisplayAlignment", return Host::TranslateToCString("Settings", s_display_alignment_display_names[static_cast<size_t>(alignment)],
s_display_alignment_display_names[static_cast<size_t>(alignment)]); "DisplayAlignment");
} }
static constexpr const std::array s_display_rotation_names = {"Normal", "Rotate90", "Rotate180", "Rotate270"}; static constexpr const std::array s_display_rotation_names = {"Normal", "Rotate90", "Rotate180", "Rotate270"};
static constexpr const std::array s_display_rotation_display_names = { static constexpr const std::array s_display_rotation_display_names = {
TRANSLATE_NOOP("Settings", "No Rotation"), TRANSLATE_DISAMBIG_NOOP("Settings", "No Rotation", "DisplayRotation"),
TRANSLATE_NOOP("Settings", "Rotate 90° (Clockwise)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Rotate 90° (Clockwise)", "DisplayRotation"),
TRANSLATE_NOOP("Settings", "Rotate 180° (Vertical Flip)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Rotate 180° (Vertical Flip)", "DisplayRotation"),
TRANSLATE_NOOP("Settings", "Rotate 270° (Clockwise)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Rotate 270° (Clockwise)", "DisplayRotation"),
}; };
std::optional<DisplayRotation> Settings::ParseDisplayRotation(const char* str) std::optional<DisplayRotation> Settings::ParseDisplayRotation(const char* str)
@ -1511,19 +1550,26 @@ const char* Settings::GetDisplayRotationName(DisplayRotation rotation)
const char* Settings::GetDisplayRotationDisplayName(DisplayRotation rotation) const char* Settings::GetDisplayRotationDisplayName(DisplayRotation rotation)
{ {
return Host::TranslateToCString("Settings", s_display_rotation_display_names[static_cast<size_t>(rotation)]); return Host::TranslateToCString("Settings", s_display_rotation_display_names[static_cast<size_t>(rotation)],
"DisplayRotation");
} }
static constexpr const std::array s_display_force_video_timings_names = { static constexpr const std::array s_display_force_video_timing_names = {
TRANSLATE_NOOP("Settings", "Disabled"), "Disabled",
"NTSC", "NTSC",
"PAL", "PAL",
}; };
static constexpr const std::array s_display_force_video_timing_display_names = {
TRANSLATE_DISAMBIG_NOOP("Settings", "Disabled", "ForceVideoTiming"),
TRANSLATE_DISAMBIG_NOOP("Settings", "NTSC (60hz)", "ForceVideoTiming"),
TRANSLATE_DISAMBIG_NOOP("Settings", "PAL (50hz)", "ForceVideoTiming"),
};
std::optional<ForceVideoTimingMode> Settings::ParseForceVideoTimingName(const char* str) std::optional<ForceVideoTimingMode> Settings::ParseForceVideoTimingName(const char* str)
{ {
int index = 0; int index = 0;
for (const char* name : s_display_force_video_timings_names) for (const char* name : s_display_force_video_timing_names)
{ {
if (StringUtil::Strcasecmp(name, str) == 0) if (StringUtil::Strcasecmp(name, str) == 0)
return static_cast<ForceVideoTimingMode>(index); return static_cast<ForceVideoTimingMode>(index);
@ -1536,23 +1582,24 @@ std::optional<ForceVideoTimingMode> Settings::ParseForceVideoTimingName(const ch
const char* Settings::GetForceVideoTimingName(ForceVideoTimingMode mode) const char* Settings::GetForceVideoTimingName(ForceVideoTimingMode mode)
{ {
return s_display_force_video_timings_names[static_cast<size_t>(mode)]; return s_display_force_video_timing_names[static_cast<size_t>(mode)];
} }
const char* Settings::GetForceVideoTimingDisplayName(ForceVideoTimingMode mode) const char* Settings::GetForceVideoTimingDisplayName(ForceVideoTimingMode mode)
{ {
return Host::TranslateToCString("Settings", s_display_force_video_timings_names[static_cast<size_t>(mode)]); return Host::TranslateToCString("Settings", s_display_force_video_timing_display_names[static_cast<size_t>(mode)],
"ForceVideoTiming");
} }
static constexpr const std::array s_display_scaling_names = { static constexpr const std::array s_display_scaling_names = {
"Nearest", "NearestInteger", "BilinearSmooth", "BilinearSharp", "BilinearInteger", "Nearest", "NearestInteger", "BilinearSmooth", "BilinearSharp", "BilinearInteger",
}; };
static constexpr const std::array s_display_scaling_display_names = { static constexpr const std::array s_display_scaling_display_names = {
TRANSLATE_NOOP("DisplayScalingMode", "Nearest-Neighbor"), TRANSLATE_DISAMBIG_NOOP("Settings", "Nearest-Neighbor", "DisplayScalingMode"),
TRANSLATE_NOOP("DisplayScalingMode", "Nearest-Neighbor (Integer)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Nearest-Neighbor (Integer)", "DisplayScalingMode"),
TRANSLATE_NOOP("DisplayScalingMode", "Bilinear (Smooth)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Bilinear (Smooth)", "DisplayScalingMode"),
TRANSLATE_NOOP("DisplayScalingMode", "Bilinear (Sharp)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Bilinear (Sharp)", "DisplayScalingMode"),
TRANSLATE_NOOP("DisplayScalingMode", "Bilinear (Integer)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Bilinear (Integer)", "DisplayScalingMode"),
}; };
std::optional<DisplayScalingMode> Settings::ParseDisplayScaling(const char* str) std::optional<DisplayScalingMode> Settings::ParseDisplayScaling(const char* str)
@ -1576,7 +1623,8 @@ const char* Settings::GetDisplayScalingName(DisplayScalingMode mode)
const char* Settings::GetDisplayScalingDisplayName(DisplayScalingMode mode) const char* Settings::GetDisplayScalingDisplayName(DisplayScalingMode mode)
{ {
return Host::TranslateToCString("DisplayScalingMode", s_display_scaling_display_names[static_cast<size_t>(mode)]); return Host::TranslateToCString("Settings", s_display_scaling_display_names[static_cast<size_t>(mode)],
"DisplayScalingMode");
} }
static constexpr const std::array s_display_exclusive_fullscreen_mode_names = { static constexpr const std::array s_display_exclusive_fullscreen_mode_names = {
@ -1585,9 +1633,9 @@ static constexpr const std::array s_display_exclusive_fullscreen_mode_names = {
"Allowed", "Allowed",
}; };
static constexpr const std::array s_display_exclusive_fullscreen_mode_display_names = { static constexpr const std::array s_display_exclusive_fullscreen_mode_display_names = {
TRANSLATE_NOOP("Settings", "Automatic"), TRANSLATE_DISAMBIG_NOOP("Settings", "Automatic", "DisplayExclusiveFullscreenControl"),
TRANSLATE_NOOP("Settings", "Disallowed"), TRANSLATE_DISAMBIG_NOOP("Settings", "Disallowed", "DisplayExclusiveFullscreenControl"),
TRANSLATE_NOOP("Settings", "Allowed"), TRANSLATE_DISAMBIG_NOOP("Settings", "Allowed", "DisplayExclusiveFullscreenControl"),
}; };
std::optional<DisplayExclusiveFullscreenControl> Settings::ParseDisplayExclusiveFullscreenControl(const char* str) std::optional<DisplayExclusiveFullscreenControl> Settings::ParseDisplayExclusiveFullscreenControl(const char* str)
@ -1612,7 +1660,8 @@ const char* Settings::GetDisplayExclusiveFullscreenControlName(DisplayExclusiveF
const char* Settings::GetDisplayExclusiveFullscreenControlDisplayName(DisplayExclusiveFullscreenControl mode) const char* Settings::GetDisplayExclusiveFullscreenControlDisplayName(DisplayExclusiveFullscreenControl mode)
{ {
return Host::TranslateToCString("Settings", return Host::TranslateToCString("Settings",
s_display_exclusive_fullscreen_mode_display_names[static_cast<size_t>(mode)]); s_display_exclusive_fullscreen_mode_display_names[static_cast<size_t>(mode)],
"DisplayExclusiveFullscreenControl");
} }
static constexpr const std::array s_display_screenshot_mode_names = { static constexpr const std::array s_display_screenshot_mode_names = {
@ -1621,9 +1670,9 @@ static constexpr const std::array s_display_screenshot_mode_names = {
"UncorrectedInternalResolution", "UncorrectedInternalResolution",
}; };
static constexpr const std::array s_display_screenshot_mode_display_names = { static constexpr const std::array s_display_screenshot_mode_display_names = {
TRANSLATE_NOOP("Settings", "Screen Resolution"), TRANSLATE_DISAMBIG_NOOP("Settings", "Screen Resolution", "DisplayScreenshotMode"),
TRANSLATE_NOOP("Settings", "Internal Resolution"), TRANSLATE_DISAMBIG_NOOP("Settings", "Internal Resolution", "DisplayScreenshotMode"),
TRANSLATE_NOOP("Settings", "Internal Resolution (Aspect Uncorrected)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Internal Resolution (Aspect Uncorrected)", "DisplayScreenshotMode"),
}; };
std::optional<DisplayScreenshotMode> Settings::ParseDisplayScreenshotMode(const char* str) std::optional<DisplayScreenshotMode> Settings::ParseDisplayScreenshotMode(const char* str)
@ -1647,7 +1696,8 @@ const char* Settings::GetDisplayScreenshotModeName(DisplayScreenshotMode mode)
const char* Settings::GetDisplayScreenshotModeDisplayName(DisplayScreenshotMode mode) const char* Settings::GetDisplayScreenshotModeDisplayName(DisplayScreenshotMode mode)
{ {
return Host::TranslateToCString("Settings", s_display_screenshot_mode_display_names[static_cast<size_t>(mode)]); return Host::TranslateToCString("Settings", s_display_screenshot_mode_display_names[static_cast<size_t>(mode)],
"DisplayScreenshotMode");
} }
static constexpr const std::array s_display_screenshot_format_names = { static constexpr const std::array s_display_screenshot_format_names = {
@ -1656,9 +1706,9 @@ static constexpr const std::array s_display_screenshot_format_names = {
"WebP", "WebP",
}; };
static constexpr const std::array s_display_screenshot_format_display_names = { static constexpr const std::array s_display_screenshot_format_display_names = {
TRANSLATE_NOOP("Settings", "PNG"), TRANSLATE_DISAMBIG_NOOP("Settings", "PNG", "DisplayScreenshotFormat"),
TRANSLATE_NOOP("Settings", "JPEG"), TRANSLATE_DISAMBIG_NOOP("Settings", "JPEG", "DisplayScreenshotFormat"),
TRANSLATE_NOOP("Settings", "WebP"), TRANSLATE_DISAMBIG_NOOP("Settings", "WebP", "DisplayScreenshotFormat"),
}; };
static constexpr const std::array s_display_screenshot_format_extensions = { static constexpr const std::array s_display_screenshot_format_extensions = {
"png", "png",
@ -1687,7 +1737,8 @@ const char* Settings::GetDisplayScreenshotFormatName(DisplayScreenshotFormat for
const char* Settings::GetDisplayScreenshotFormatDisplayName(DisplayScreenshotFormat mode) const char* Settings::GetDisplayScreenshotFormatDisplayName(DisplayScreenshotFormat mode)
{ {
return Host::TranslateToCString("Settings", s_display_screenshot_format_display_names[static_cast<size_t>(mode)]); return Host::TranslateToCString("Settings", s_display_screenshot_format_display_names[static_cast<size_t>(mode)],
"DisplayScreenshotFormat");
} }
const char* Settings::GetDisplayScreenshotFormatExtension(DisplayScreenshotFormat format) const char* Settings::GetDisplayScreenshotFormatExtension(DisplayScreenshotFormat format)
@ -1695,15 +1746,17 @@ const char* Settings::GetDisplayScreenshotFormatExtension(DisplayScreenshotForma
return s_display_screenshot_format_extensions[static_cast<size_t>(format)]; return s_display_screenshot_format_extensions[static_cast<size_t>(format)];
} }
static constexpr const std::array s_memory_card_type_names = {"None", "Shared", "PerGame", static constexpr const std::array s_memory_card_type_names = {
"PerGameTitle", "PerGameFileTitle", "NonPersistent"}; "None", "Shared", "PerGame", "PerGameTitle", "PerGameFileTitle", "NonPersistent",
};
static constexpr const std::array s_memory_card_type_display_names = { static constexpr const std::array s_memory_card_type_display_names = {
TRANSLATE_NOOP("MemoryCardType", "No Memory Card"), TRANSLATE_DISAMBIG_NOOP("Settings", "No Memory Card", "MemoryCardType"),
TRANSLATE_NOOP("MemoryCardType", "Shared Between All Games"), TRANSLATE_DISAMBIG_NOOP("Settings", "Shared Between All Games", "MemoryCardType"),
TRANSLATE_NOOP("MemoryCardType", "Separate Card Per Game (Serial)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Separate Card Per Game (Serial)", "MemoryCardType"),
TRANSLATE_NOOP("MemoryCardType", "Separate Card Per Game (Title)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Separate Card Per Game (Title)", "MemoryCardType"),
TRANSLATE_NOOP("MemoryCardType", "Separate Card Per Game (File Title)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Separate Card Per Game (File Title)", "MemoryCardType"),
TRANSLATE_NOOP("MemoryCardType", "Non-Persistent Card (Do Not Save)")}; TRANSLATE_DISAMBIG_NOOP("Settings", "Non-Persistent Card (Do Not Save)", "MemoryCardType"),
};
std::optional<MemoryCardType> Settings::ParseMemoryCardTypeName(const char* str) std::optional<MemoryCardType> Settings::ParseMemoryCardTypeName(const char* str)
{ {
@ -1726,7 +1779,8 @@ const char* Settings::GetMemoryCardTypeName(MemoryCardType type)
const char* Settings::GetMemoryCardTypeDisplayName(MemoryCardType type) const char* Settings::GetMemoryCardTypeDisplayName(MemoryCardType type)
{ {
return Host::TranslateToCString("MemoryCardType", s_memory_card_type_display_names[static_cast<size_t>(type)]); return Host::TranslateToCString("Settings", s_memory_card_type_display_names[static_cast<size_t>(type)],
"MemoryCardType");
} }
std::string Settings::GetDefaultSharedMemoryCardName(u32 slot) std::string Settings::GetDefaultSharedMemoryCardName(u32 slot)
@ -1753,10 +1807,18 @@ std::string Settings::GetGameMemoryCardPath(std::string_view serial, u32 slot)
return Path::Combine(EmuFolders::MemoryCards, fmt::format("{}_{}.mcd", serial, slot + 1)); return Path::Combine(EmuFolders::MemoryCards, fmt::format("{}_{}.mcd", serial, slot + 1));
} }
static constexpr const std::array s_multitap_enable_mode_names = {"Disabled", "Port1Only", "Port2Only", "BothPorts"}; static constexpr const std::array s_multitap_enable_mode_names = {
"Disabled",
"Port1Only",
"Port2Only",
"BothPorts",
};
static constexpr const std::array s_multitap_enable_mode_display_names = { static constexpr const std::array s_multitap_enable_mode_display_names = {
TRANSLATE_NOOP("MultitapMode", "Disabled"), TRANSLATE_NOOP("MultitapMode", "Enable on Port 1 Only"), TRANSLATE_DISAMBIG_NOOP("Settings", "Disabled", "MultitapMode"),
TRANSLATE_NOOP("MultitapMode", "Enable on Port 2 Only"), TRANSLATE_NOOP("MultitapMode", "Enable on Ports 1 and 2")}; TRANSLATE_DISAMBIG_NOOP("Settings", "Enable on Port 1 Only", "MultitapMode"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Enable on Port 2 Only", "MultitapMode"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Enable on Ports 1 and 2", "MultitapMode"),
};
std::optional<MultitapMode> Settings::ParseMultitapModeName(const char* str) std::optional<MultitapMode> Settings::ParseMultitapModeName(const char* str)
{ {
@ -1779,7 +1841,8 @@ const char* Settings::GetMultitapModeName(MultitapMode mode)
const char* Settings::GetMultitapModeDisplayName(MultitapMode mode) const char* Settings::GetMultitapModeDisplayName(MultitapMode mode)
{ {
return Host::TranslateToCString("MultitapMode", s_multitap_enable_mode_display_names[static_cast<size_t>(mode)]); return Host::TranslateToCString("Settings", s_multitap_enable_mode_display_names[static_cast<size_t>(mode)],
"MultitapMode");
} }
static constexpr const std::array s_mechacon_version_names = {"VC0A", "VC0B", "VC1A", "VC1B", "VD1", "VC2", "VC1", static constexpr const std::array s_mechacon_version_names = {"VC0A", "VC0B", "VC1A", "VC1B", "VD1", "VC2", "VC1",
@ -1817,10 +1880,13 @@ static constexpr const std::array s_save_state_compression_mode_names = {
"Uncompressed", "DeflateLow", "DeflateDefault", "DeflateHigh", "ZstLow", "ZstDefault", "ZstHigh", "Uncompressed", "DeflateLow", "DeflateDefault", "DeflateHigh", "ZstLow", "ZstDefault", "ZstHigh",
}; };
static constexpr const std::array s_save_state_compression_mode_display_names = { static constexpr const std::array s_save_state_compression_mode_display_names = {
TRANSLATE_NOOP("Settings", "Uncompressed"), TRANSLATE_NOOP("Settings", "Deflate (Low)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Uncompressed", "SaveStateCompressionMode"),
TRANSLATE_NOOP("Settings", "Deflate (Default)"), TRANSLATE_NOOP("Settings", "Deflate (High)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Deflate (Low)", "SaveStateCompressionMode"),
TRANSLATE_NOOP("Settings", "Zstandard (Low)"), TRANSLATE_NOOP("Settings", "Zstandard (Default)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Deflate (Default)", "SaveStateCompressionMode"),
TRANSLATE_NOOP("Settings", "Zstandard (High)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Deflate (High)", "SaveStateCompressionMode"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Zstandard (Low)", "SaveStateCompressionMode"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Zstandard (Default)", "SaveStateCompressionMode"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Zstandard (High)", "SaveStateCompressionMode"),
}; };
static_assert(s_save_state_compression_mode_names.size() == static_cast<size_t>(SaveStateCompressionMode::Count)); static_assert(s_save_state_compression_mode_names.size() == static_cast<size_t>(SaveStateCompressionMode::Count));
static_assert(s_save_state_compression_mode_display_names.size() == static_assert(s_save_state_compression_mode_display_names.size() ==
@ -1847,7 +1913,8 @@ const char* Settings::GetSaveStateCompressionModeName(SaveStateCompressionMode m
const char* Settings::GetSaveStateCompressionModeDisplayName(SaveStateCompressionMode mode) const char* Settings::GetSaveStateCompressionModeDisplayName(SaveStateCompressionMode mode)
{ {
return Host::TranslateToCString("Settings", s_save_state_compression_mode_display_names[static_cast<size_t>(mode)]); return Host::TranslateToCString("Settings", s_save_state_compression_mode_display_names[static_cast<size_t>(mode)],
"SaveStateCompressionMode");
} }
std::string EmuFolders::AppRoot; std::string EmuFolders::AppRoot;

View file

@ -649,7 +649,7 @@ void GraphicsSettingsWidget::setupAdditionalUi()
for (u32 i = 0; i < static_cast<u32>(ForceVideoTimingMode::Count); i++) for (u32 i = 0; i < static_cast<u32>(ForceVideoTimingMode::Count); i++)
{ {
m_ui.forceVideoTiming->addItem( m_ui.forceVideoTiming->addItem(
QString::fromUtf8(Settings::GetForceVideoTimingName(static_cast<ForceVideoTimingMode>(i)))); QString::fromUtf8(Settings::GetForceVideoTimingDisplayName(static_cast<ForceVideoTimingMode>(i))));
} }
// Advanced Tab // Advanced Tab

View file

@ -156,13 +156,15 @@ QString QtHost::FixLanguageName(const QString& language)
return language; return language;
} }
s32 Host::Internal::GetTranslatedStringImpl(std::string_view context, std::string_view msg, char* tbuf, s32 Host::Internal::GetTranslatedStringImpl(std::string_view context, std::string_view msg,
size_t tbuf_space) std::string_view disambiguation, char* tbuf, size_t tbuf_space)
{ {
// This is really awful. Thankfully we're caching the results... // This is really awful. Thankfully we're caching the results...
const std::string temp_context(context); const std::string temp_context(context);
const std::string temp_msg(msg); const std::string temp_msg(msg);
const QString translated_msg = qApp->translate(temp_context.c_str(), temp_msg.c_str()); const std::string temp_disambiguation(disambiguation);
const QString translated_msg = qApp->translate(temp_context.c_str(), temp_msg.c_str(),
disambiguation.empty() ? nullptr : temp_disambiguation.c_str());
const QByteArray translated_utf8 = translated_msg.toUtf8(); const QByteArray translated_utf8 = translated_msg.toUtf8();
const size_t translated_size = translated_utf8.size(); const size_t translated_size = translated_utf8.size();
if (translated_size > tbuf_space) if (translated_size > tbuf_space)

View file

@ -66,7 +66,7 @@ REM A good .ts file has been passed
ECHO Updating %filename%... ECHO Updating %filename%...
ECHO. ECHO.
SET "linguist=..\..\..\dep\msvc\deps-x64\bin" SET "linguist=..\..\..\dep\msvc\deps-x64\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,translate+=TRANSLATE_PLURAL_STR,translate+=TRANSLATE_PLURAL_SSTR,translate+=TRANSLATE_PLURAL_FS" 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_NOOP3+=TRANSLATE_DISAMBIG,QT_TRANSLATE_NOOP3+=TRANSLATE_DISAMBIG_SV,QT_TRANSLATE_NOOP3+=TRANSLATE_DISAMBIG_STR,QT_TRANSLATE_NOOP3+=TRANSLATE_DISAMBIG_FS,QT_TRANSLATE_N_NOOP3+=TRANSLATE_FMT,QT_TRANSLATE_NOOP+=TRANSLATE_NOOP,QT_TRANSLATE_NOOP3+=TRANSLATE_DISAMBIG_NOOP,translate+=TRANSLATE_PLURAL_STR,translate+=TRANSLATE_PLURAL_SSTR,translate+=TRANSLATE_PLURAL_FS"
"%linguist%\lupdate.exe" %context% -ts %filename% "%linguist%\lupdate.exe" %context% -ts %filename%
ECHO. ECHO.

View file

@ -1,24 +0,0 @@
@echo off
echo Set your language
echo.
echo Examples:
echo en ^<-- English
echo en-au ^<-- Australian English
echo ^<-- Remove language setting
echo.
echo For the 369-1 2-digit language code
echo https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
echo.
echo If you require a country code as well (you probably don't)
echo https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
echo.
echo.%lang%
set /p newlang="Enter language code: "
if defined newlang ( setx lang %newlang% )
if defined lang if not defined newlang (
echo Removing language setting...
setx lang "" 1>nul
reg delete HKCU\Environment /F /V lang 2>nul
reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /F /V lang 2>nul
)
pause

View file

@ -1,7 +1,7 @@
@echo off @echo off
set "linguist=..\..\..\dep\msvc\deps-x64\bin" set "linguist=..\..\..\dep\msvc\deps-x64\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,translate+=TRANSLATE_PLURAL_STR,translate+=TRANSLATE_PLURAL_SSTR,translate+=TRANSLATE_PLURAL_FS -pluralonly -no-obsolete 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_NOOP3+=TRANSLATE_DISAMBIG,QT_TRANSLATE_NOOP3+=TRANSLATE_DISAMBIG_SV,QT_TRANSLATE_NOOP3+=TRANSLATE_DISAMBIG_STR,QT_TRANSLATE_NOOP3+=TRANSLATE_DISAMBIG_FS,QT_TRANSLATE_N_NOOP3+=TRANSLATE_FMT,QT_TRANSLATE_NOOP+=TRANSLATE_NOOP,QT_TRANSLATE_NOOP3+=TRANSLATE_DISAMBIG_NOOP,translate+=TRANSLATE_PLURAL_STR,translate+=TRANSLATE_PLURAL_SSTR,translate+=TRANSLATE_PLURAL_FS -pluralonly -no-obsolete
"%linguist%\lupdate.exe" %context% -ts duckstation-qt_en.ts "%linguist%\lupdate.exe" %context% -ts duckstation-qt_en.ts
pause pause

View file

@ -1,12 +0,0 @@
@echo off
if not defined lang (echo Please set your language first & pause & exit)
set "linguist=..\..\..\dep\msvc\deps-x64\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,translate+=TRANSLATE_PLURAL_STR,translate+=TRANSLATE_PLURAL_SSTR,translate+=TRANSLATE_PLURAL_FS"
"%linguist%\lupdate.exe" %context% -noobsolete -ts duckstation-qt_%lang%.ts
pause
cd "%linguist%"
start /B linguist.exe "%~dp0\duckstation-qt_%lang%.ts"

View file

@ -281,10 +281,10 @@ static constexpr const std::array s_backend_names = {
#endif #endif
}; };
static constexpr const std::array s_backend_display_names = { static constexpr const std::array s_backend_display_names = {
TRANSLATE_NOOP("AudioStream", "Null (No Output)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Null (No Output)", "AudioBackend"),
#ifndef __ANDROID__ #ifndef __ANDROID__
TRANSLATE_NOOP("AudioStream", "Cubeb"), TRANSLATE_DISAMBIG_NOOP("Settings", "Cubeb", "AudioBackend"),
TRANSLATE_NOOP("AudioStream", "SDL"), TRANSLATE_DISAMBIG_NOOP("Settings", "SDL", "AudioBackend"),
#else #else
"AAudio", "AAudio",
"OpenSL ES", "OpenSL ES",
@ -319,20 +319,26 @@ static constexpr const std::array s_expansion_mode_names = {
"Disabled", "StereoLFE", "Quadraphonic", "QuadraphonicLFE", "Surround51", "Surround71", "Disabled", "StereoLFE", "Quadraphonic", "QuadraphonicLFE", "Surround51", "Surround71",
}; };
static constexpr const std::array s_expansion_mode_display_names = { static constexpr const std::array s_expansion_mode_display_names = {
TRANSLATE_NOOP("AudioStream", "Disabled (Stereo)"), TRANSLATE_NOOP("AudioStream", "Stereo with LFE"), TRANSLATE_DISAMBIG_NOOP("Settings", "Disabled (Stereo)", "AudioExpansionMode"),
TRANSLATE_NOOP("AudioStream", "Quadraphonic"), TRANSLATE_NOOP("AudioStream", "Quadraphonic with LFE"), TRANSLATE_DISAMBIG_NOOP("Settings", "Stereo with LFE", "AudioExpansionMode"),
TRANSLATE_NOOP("AudioStream", "5.1 Surround"), TRANSLATE_NOOP("AudioStream", "7.1 Surround"), TRANSLATE_DISAMBIG_NOOP("Settings", "Quadraphonic", "AudioExpansionMode"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Quadraphonic with LFE", "AudioExpansionMode"),
TRANSLATE_DISAMBIG_NOOP("Settings", "5.1 Surround", "AudioExpansionMode"),
TRANSLATE_DISAMBIG_NOOP("Settings", "7.1 Surround", "AudioExpansionMode"),
}; };
const char* AudioStream::GetExpansionModeName(AudioExpansionMode mode) const char* AudioStream::GetExpansionModeName(AudioExpansionMode mode)
{ {
return (static_cast<u32>(mode) < s_expansion_mode_names.size()) ? s_expansion_mode_names[static_cast<u32>(mode)] : ""; return (static_cast<size_t>(mode) < s_expansion_mode_names.size()) ?
s_expansion_mode_names[static_cast<size_t>(mode)] :
"";
} }
const char* AudioStream::GetExpansionModeDisplayName(AudioExpansionMode mode) const char* AudioStream::GetExpansionModeDisplayName(AudioExpansionMode mode)
{ {
return (static_cast<u32>(mode) < s_expansion_mode_display_names.size()) ? return (static_cast<size_t>(mode) < s_expansion_mode_display_names.size()) ?
Host::TranslateToCString("AudioStream", s_expansion_mode_display_names[static_cast<u32>(mode)]) : Host::TranslateToCString("Settings", s_expansion_mode_display_names[static_cast<size_t>(mode)],
"AudioExpansionMode") :
""; "";
} }
@ -353,26 +359,28 @@ static constexpr const std::array s_stretch_mode_names = {
"TimeStretch", "TimeStretch",
}; };
static constexpr const std::array s_stretch_mode_display_names = { static constexpr const std::array s_stretch_mode_display_names = {
TRANSLATE_NOOP("AudioStream", "Off (Noisy)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Off (Noisy)", "AudioStretchMode"),
TRANSLATE_NOOP("AudioStream", "Resampling (Pitch Shift)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Resampling (Pitch Shift)", "AudioStretchMode"),
TRANSLATE_NOOP("AudioStream", "Time Stretch (Tempo Change, Best Sound)"), TRANSLATE_DISAMBIG_NOOP("Settings", "Time Stretch (Tempo Change, Best Sound)", "AudioStretchMode"),
}; };
const char* AudioStream::GetStretchModeName(AudioStretchMode mode) const char* AudioStream::GetStretchModeName(AudioStretchMode mode)
{ {
return (static_cast<u32>(mode) < s_stretch_mode_names.size()) ? s_stretch_mode_names[static_cast<u32>(mode)] : ""; return (static_cast<size_t>(mode) < s_stretch_mode_names.size()) ? s_stretch_mode_names[static_cast<size_t>(mode)] :
"";
} }
const char* AudioStream::GetStretchModeDisplayName(AudioStretchMode mode) const char* AudioStream::GetStretchModeDisplayName(AudioStretchMode mode)
{ {
return (static_cast<u32>(mode) < s_stretch_mode_display_names.size()) ? return (static_cast<size_t>(mode) < s_stretch_mode_display_names.size()) ?
Host::TranslateToCString("AudioStream", s_stretch_mode_display_names[static_cast<u32>(mode)]) : Host::TranslateToCString("Settings", s_stretch_mode_display_names[static_cast<size_t>(mode)],
"AudioStretchMode") :
""; "";
} }
std::optional<AudioStretchMode> AudioStream::ParseStretchMode(const char* name) std::optional<AudioStretchMode> AudioStream::ParseStretchMode(const char* name)
{ {
for (u8 i = 0; i < static_cast<u8>(AudioStretchMode::Count); i++) for (size_t i = 0; i < static_cast<u8>(AudioStretchMode::Count); i++)
{ {
if (std::strcmp(name, s_stretch_mode_names[i]) == 0) if (std::strcmp(name, s_stretch_mode_names[i]) == 0)
return static_cast<AudioStretchMode>(i); return static_cast<AudioStretchMode>(i);

View file

@ -14,7 +14,8 @@
Log_SetChannel(Host); Log_SetChannel(Host);
namespace Host { namespace Host {
static std::pair<const char*, u32> LookupTranslationString(std::string_view context, std::string_view msg); static std::pair<const char*, u32> LookupTranslationString(std::string_view context, std::string_view msg,
std::string_view disambiguation);
static constexpr u32 TRANSLATION_STRING_CACHE_SIZE = 4 * 1024 * 1024; static constexpr u32 TRANSLATION_STRING_CACHE_SIZE = 4 * 1024 * 1024;
using TranslationStringMap = PreferUnorderedStringMap<std::pair<u32, u32>>; using TranslationStringMap = PreferUnorderedStringMap<std::pair<u32, u32>>;
@ -25,13 +26,15 @@ static std::vector<char> s_translation_string_cache;
static u32 s_translation_string_cache_pos; static u32 s_translation_string_cache_pos;
} // namespace Host } // namespace Host
std::pair<const char*, u32> Host::LookupTranslationString(std::string_view context, std::string_view msg) std::pair<const char*, u32> Host::LookupTranslationString(std::string_view context, std::string_view msg,
std::string_view disambiguation)
{ {
// TODO: TranslatableString, compile-time hashing. // TODO: TranslatableString, compile-time hashing.
TranslationStringContextMap::iterator ctx_it; TranslationStringContextMap::iterator ctx_it;
TranslationStringMap::iterator msg_it; TranslationStringMap::iterator msg_it;
std::pair<const char*, u32> ret; std::pair<const char*, u32> ret;
SmallString disambiguation_key;
s32 len; s32 len;
// Shouldn't happen, but just in case someone tries to translate an empty string. // Shouldn't happen, but just in case someone tries to translate an empty string.
@ -42,13 +45,19 @@ std::pair<const char*, u32> Host::LookupTranslationString(std::string_view conte
return ret; return ret;
} }
if (!disambiguation.empty())
{
disambiguation_key.append(disambiguation);
disambiguation_key.append(msg);
}
s_translation_string_mutex.lock_shared(); s_translation_string_mutex.lock_shared();
ctx_it = s_translation_string_map.find(context); ctx_it = s_translation_string_map.find(context);
if (ctx_it == s_translation_string_map.end()) [[unlikely]] if (ctx_it == s_translation_string_map.end()) [[unlikely]]
goto add_string; goto add_string;
msg_it = ctx_it->second.find(msg); msg_it = ctx_it->second.find(disambiguation.empty() ? msg : disambiguation_key.view());
if (msg_it == ctx_it->second.end()) [[unlikely]] if (msg_it == ctx_it->second.end()) [[unlikely]]
goto add_string; goto add_string;
@ -69,14 +78,14 @@ add_string:
s_translation_string_cache_pos = 0; s_translation_string_cache_pos = 0;
} }
if ((len = if ((len = Internal::GetTranslatedStringImpl(context, msg, disambiguation,
Internal::GetTranslatedStringImpl(context, msg, &s_translation_string_cache[s_translation_string_cache_pos], &s_translation_string_cache[s_translation_string_cache_pos],
TRANSLATION_STRING_CACHE_SIZE - 1 - s_translation_string_cache_pos)) < 0) TRANSLATION_STRING_CACHE_SIZE - 1 - s_translation_string_cache_pos)) < 0)
{ {
ERROR_LOG("WARNING: Clearing translation string cache, it might need to be larger."); ERROR_LOG("WARNING: Clearing translation string cache, it might need to be larger.");
s_translation_string_cache_pos = 0; s_translation_string_cache_pos = 0;
if ((len = if ((len = Internal::GetTranslatedStringImpl(
Internal::GetTranslatedStringImpl(context, msg, &s_translation_string_cache[s_translation_string_cache_pos], context, msg, disambiguation, &s_translation_string_cache[s_translation_string_cache_pos],
TRANSLATION_STRING_CACHE_SIZE - 1 - s_translation_string_cache_pos)) < 0) TRANSLATION_STRING_CACHE_SIZE - 1 - s_translation_string_cache_pos)) < 0)
{ {
Panic("Failed to get translated string after clearing cache."); Panic("Failed to get translated string after clearing cache.");
@ -93,7 +102,8 @@ add_string:
const u32 insert_pos = s_translation_string_cache_pos; const u32 insert_pos = s_translation_string_cache_pos;
s_translation_string_cache[insert_pos + static_cast<u32>(len)] = 0; 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))); ctx_it->second.emplace(disambiguation.empty() ? msg : disambiguation_key.view(),
std::pair<u32, u32>(insert_pos, static_cast<u32>(len)));
s_translation_string_cache_pos = insert_pos + static_cast<u32>(len) + 1; s_translation_string_cache_pos = insert_pos + static_cast<u32>(len) + 1;
ret.first = &s_translation_string_cache[insert_pos]; ret.first = &s_translation_string_cache[insert_pos];
@ -102,20 +112,21 @@ add_string:
return ret; return ret;
} }
const char* Host::TranslateToCString(std::string_view context, std::string_view msg) const char* Host::TranslateToCString(std::string_view context, std::string_view msg, std::string_view disambiguation)
{ {
return LookupTranslationString(context, msg).first; return LookupTranslationString(context, msg, disambiguation).first;
} }
std::string_view Host::TranslateToStringView(std::string_view context, std::string_view msg) std::string_view Host::TranslateToStringView(std::string_view context, std::string_view msg,
std::string_view disambiguation)
{ {
const auto mp = LookupTranslationString(context, msg); const auto mp = LookupTranslationString(context, msg, disambiguation);
return std::string_view(mp.first, mp.second); return std::string_view(mp.first, mp.second);
} }
std::string Host::TranslateToString(std::string_view context, std::string_view msg) std::string Host::TranslateToString(std::string_view context, std::string_view msg, std::string_view disambiguation)
{ {
return std::string(TranslateToStringView(context, msg)); return std::string(TranslateToStringView(context, msg, disambiguation));
} }
void Host::ClearTranslationCache() void Host::ClearTranslationCache()

View file

@ -50,16 +50,17 @@ bool CopyTextToClipboard(std::string_view text);
/// Returns a localized version of the specified string within the specified context. /// Returns a localized version of the specified string within the specified context.
/// The pointer is guaranteed to be valid until the next language change. /// The pointer is guaranteed to be valid until the next language change.
const char* TranslateToCString(std::string_view context, std::string_view msg); const char* TranslateToCString(std::string_view context, std::string_view msg, std::string_view disambiguation = {});
/// Returns a localized version of the specified string within the specified context. /// Returns a localized version of the specified string within the specified context.
/// The view is guaranteed to be valid until the next language change. /// The view is guaranteed to be valid until the next language change.
/// NOTE: When passing this to fmt, positional arguments should be used in the base string, as /// NOTE: When passing this to fmt, positional arguments should be used in the base string, as
/// not all locales follow the same word ordering. /// not all locales follow the same word ordering.
std::string_view TranslateToStringView(std::string_view context, std::string_view msg); std::string_view TranslateToStringView(std::string_view context, std::string_view msg,
std::string_view disambiguation = {});
/// Returns a localized version of the specified string within the specified context. /// Returns a localized version of the specified string within the specified context.
std::string TranslateToString(std::string_view context, std::string_view msg); std::string TranslateToString(std::string_view context, std::string_view msg, std::string_view disambiguation = {});
/// Returns a localized version of the specified string within the specified context, adjusting for plurals using %n. /// Returns a localized version of the specified string within the specified context, adjusting for plurals using %n.
std::string TranslatePluralToString(const char* context, const char* msg, const char* disambiguation, int count); std::string TranslatePluralToString(const char* context, const char* msg, const char* disambiguation, int count);
@ -70,7 +71,8 @@ void ClearTranslationCache();
namespace Internal { namespace Internal {
/// Implementation to retrieve a translated string. /// Implementation to retrieve a translated string.
s32 GetTranslatedStringImpl(std::string_view context, std::string_view msg, char* tbuf, size_t tbuf_space); s32 GetTranslatedStringImpl(std::string_view context, std::string_view msg, std::string_view disambiguation, char* tbuf,
size_t tbuf_space);
} // namespace Internal } // namespace Internal
} // namespace Host } // namespace Host
@ -79,6 +81,11 @@ s32 GetTranslatedStringImpl(std::string_view context, std::string_view msg, char
#define TRANSLATE_SV(context, msg) Host::TranslateToStringView(context, msg) #define TRANSLATE_SV(context, msg) Host::TranslateToStringView(context, msg)
#define TRANSLATE_STR(context, msg) Host::TranslateToString(context, msg) #define TRANSLATE_STR(context, msg) Host::TranslateToString(context, msg)
#define TRANSLATE_FS(context, msg) fmt::runtime(Host::TranslateToStringView(context, msg)) #define TRANSLATE_FS(context, msg) fmt::runtime(Host::TranslateToStringView(context, msg))
#define TRANSLATE_DISAMBIG(context, msg, disambiguation) Host::TranslateToCString(context, msg, disambiguation)
#define TRANSLATE_DISAMBIG_SV(context, msg, disambiguation) Host::TranslateToStringView(context, msg, disambiguation)
#define TRANSLATE_DISAMBIG_STR(context, msg, disambiguation) Host::TranslateToString(context, msg, disambiguation)
#define TRANSLATE_DISAMBIG_FS(context, msg, disambiguation) \
fmt::runtime(Host::TranslateToStringView(context, msg, disambiguation))
#define TRANSLATE_PLURAL_STR(context, msg, disambiguation, count) \ #define TRANSLATE_PLURAL_STR(context, msg, disambiguation, count) \
Host::TranslatePluralToString(context, msg, disambiguation, count) Host::TranslatePluralToString(context, msg, disambiguation, count)
#define TRANSLATE_PLURAL_SSTR(context, msg, disambiguation, count) \ #define TRANSLATE_PLURAL_SSTR(context, msg, disambiguation, count) \
@ -88,3 +95,4 @@ s32 GetTranslatedStringImpl(std::string_view context, std::string_view msg, char
// Does not translate the string at runtime, but allows the UI to in its own way. // Does not translate the string at runtime, but allows the UI to in its own way.
#define TRANSLATE_NOOP(context, msg) msg #define TRANSLATE_NOOP(context, msg) msg
#define TRANSLATE_DISAMBIG_NOOP(context, msg, disambiguation) msg

View file

@ -2871,10 +2871,10 @@ static constexpr const std::array s_backend_names = {
}; };
static constexpr const std::array s_backend_display_names = { static constexpr const std::array s_backend_display_names = {
#ifdef _WIN32 #ifdef _WIN32
TRANSLATE_NOOP("MediaCapture", "Media Foundation"), TRANSLATE_DISAMBIG_NOOP("Settings", "Media Foundation", "MediaCaptureBackend"),
#endif #endif
#ifndef __ANDROID__ #ifndef __ANDROID__
TRANSLATE_NOOP("MediaCapture", "FFmpeg"), TRANSLATE_DISAMBIG_NOOP("Settings", "FFmpeg", "MediaCaptureBackend"),
#endif #endif
}; };
static_assert(s_backend_names.size() == static_cast<size_t>(MediaCaptureBackend::MaxCount)); static_assert(s_backend_names.size() == static_cast<size_t>(MediaCaptureBackend::MaxCount));
@ -2903,7 +2903,8 @@ const char* MediaCapture::GetBackendName(MediaCaptureBackend backend)
const char* MediaCapture::GetBackendDisplayName(MediaCaptureBackend backend) const char* MediaCapture::GetBackendDisplayName(MediaCaptureBackend backend)
{ {
return Host::TranslateToCString("MediaCapture", s_backend_display_names[static_cast<size_t>(backend)]); return Host::TranslateToCString("Settings", s_backend_display_names[static_cast<size_t>(backend)],
"MediaCaptureBackend");
} }
void MediaCapture::AdjustVideoSize(u32* width, u32* height) void MediaCapture::AdjustVideoSize(u32* width, u32* height)