diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bb22db33..7e6349ff9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1091,6 +1091,7 @@ set(IMGUI src/imgui/imgui_config.h src/imgui/imgui_layer.h src/imgui/imgui_std.h src/imgui/imgui_texture.h + src/imgui/imgui_translations.cpp src/imgui/imgui_translations.h src/imgui/renderer/imgui_core.cpp src/imgui/renderer/imgui_core.h @@ -1275,4 +1276,4 @@ install(TARGETS shadps4 BUNDLE DESTINATION .) else() enable_testing() add_subdirectory(tests) -endif() \ No newline at end of file +endif() diff --git a/src/imgui/imgui_translations.cpp b/src/imgui/imgui_translations.cpp new file mode 100644 index 000000000..608f980c3 --- /dev/null +++ b/src/imgui/imgui_translations.cpp @@ -0,0 +1,58 @@ +// SPDX-FileCopyrightText: Copyright 2026 shadPS4 Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/emulator_settings.h" +#include "imgui_translations.h" + +namespace ImguiTranslate { + +const std::map> langMap = { + {0, JapaneseMap}, + // {1, EnglishUsMap}, - not used + {2, FrenchMap}, + {3, SpanishMap}, + {4, GermanMap}, + {5, ItalianMap}, + {6, DutchMap}, + {7, PortugesePtMap}, + {8, RussianMap}, + {9, KoreanMap}, + {10, ChineseTraditionalMap}, + {11, ChineseSimplifiedMap}, + {12, FinnishMap}, + {13, SwedishMap}, + {14, DanishMap}, + {15, NorwegianMap}, + {16, PolishMap}, + {17, PortugeseBrMap}, + // {18, "English (UK)"}, - not used + {19, TurkishMap}, + {20, SpanishLatinAmericanMap}, + {21, ArabicMap}, + {22, FrenchCanadaMap}, + {23, CzechMap}, + {24, HungarianMap}, + {25, GreekMap}, + {26, RomanianMap}, + {27, ThaiMap}, + {28, VietnameseMap}, + {29, IndonesianMap}, + {30, UkranianMap}, +}; + +std::string tr(std::string input) { + // since we're coding in English + if (EmulatorSettings.GetConsoleLanguage() == 1 || EmulatorSettings.GetConsoleLanguage() == 18) + return input; + + const std::map translationTable = + langMap.at(EmulatorSettings.GetConsoleLanguage()); + + if (!translationTable.contains(input)) { + return input; + } + + return translationTable.at(input); +} + +} // namespace ImguiTranslate diff --git a/src/imgui/imgui_translations.h b/src/imgui/imgui_translations.h index 83f60f187..d6844b759 100644 --- a/src/imgui/imgui_translations.h +++ b/src/imgui/imgui_translations.h @@ -2,8 +2,11 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include -#include "core/emulator_settings.h" +namespace ImguiTranslate { + +std::string tr(std::string input); ///////////// ImGui Translation Tables @@ -130,55 +133,4 @@ const std::map UkranianMap = { ///////////// End ImGui Translation Tables -const std::map> langMap = { - {0, JapaneseMap}, - // {1, EnglishUsMap}, - not used - {2, FrenchMap}, - {3, SpanishMap}, - {4, GermanMap}, - {5, ItalianMap}, - {6, DutchMap}, - {7, PortugesePtMap}, - {8, RussianMap}, - {9, KoreanMap}, - {10, ChineseTraditionalMap}, - {11, ChineseSimplifiedMap}, - {12, FinnishMap}, - {13, SwedishMap}, - {14, DanishMap}, - {15, NorwegianMap}, - {16, PolishMap}, - {17, PortugeseBrMap}, - // {18, "English (UK)"}, - not used - {19, TurkishMap}, - {20, SpanishLatinAmericanMap}, - {21, ArabicMap}, - {22, FrenchCanadaMap}, - {23, CzechMap}, - {24, HungarianMap}, - {25, GreekMap}, - {26, RomanianMap}, - {27, ThaiMap}, - {28, VietnameseMap}, - {29, IndonesianMap}, - {30, UkranianMap}, -}; - -namespace ImguiTranslate { - -std::string tr(std::string input) { - // since we're coding in English - if (EmulatorSettings.GetConsoleLanguage() == 1 || EmulatorSettings.GetConsoleLanguage() == 18) - return input; - - const std::map translationTable = - langMap.at(EmulatorSettings.GetConsoleLanguage()); - - if (!translationTable.contains(input)) { - return input; - } - - return translationTable.at(input); -} - } // namespace ImguiTranslate