Add translations (#153)

* Add translations from v1

* Add font configuration (to be able to use non-latin languages)

* translations: remove includes that are already in pch.h

* translations: rename enums and avoid macros

* Fix crash when the font file doesn't exist

* translations: avoid u8 to avoid reencoding by MSVC

MSVC will read the file as ASCII and reconvert characters as UTF-8, this will corrupt characters as the file is in fact already in UTF-8.

* translations: remove NUMBER in enums

* translations: handle non existing translations gracefuly (don't crash)

Fallback to english if available, else return empty string

* Testing pull collaboration.

* Rollback: remove NUMBER in enums.

* Get rid of namespace, use header instead.

* Collapsed translated text struct and array.

* Fixed build errors and warnings.

* Simplified language list.

* All new types, locals and globals should use CamelCase.

* Removed unnecessary ImGui patch.

* Rearranged TTextBox immediate mode draw.

* Final touches: removed unused declaration in gdrv.
Removed unused Msg entries and added new check.

* Remove placeholder english texts from missing translations

Co-authored-by: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com>
This commit is contained in:
Alexis MurzeauandMuzychenko Andrey authored and GitHub committed 2022-08-31 07:58:03 +03:00
1 parent c1c74878df
commit 66a868083a
22 files changed
+7957 -461

No files matched your search

+21 -18
View File
@@ -3,6 +3,7 @@
#include "fullscrn.h"
#include "midi.h"
#include "pinball.h"
#include "render.h"
#include "Sound.h"
#include "winmain.h"
@@ -18,12 +19,12 @@ bool options::ShowDialog = false;
GameInput* options::ControlWaitingForInput = nullptr;
const ControlRef options::Controls[6]
{
{"Left Flipper", RebindControls.LeftFlipper},
{"Right Flipper", RebindControls.RightFlipper},
{"Left Table Bump", RebindControls.LeftTableBump},
{"Right Table Bump", RebindControls.RightTableBump},
{"Bottom Table Bump", RebindControls.BottomTableBump},
{"Plunger", RebindControls.Plunger},
{Msg::KEYMAPPER_FlipperL, RebindControls.LeftFlipper},
{Msg::KEYMAPPER_FlipperR, RebindControls.RightFlipper},
{Msg::KEYMAPPER_BumpLeft, RebindControls.LeftTableBump},
{Msg::KEYMAPPER_BumpRight, RebindControls.RightTableBump},
{Msg::KEYMAPPER_BumpBottom, RebindControls.BottomTableBump},
{Msg::KEYMAPPER_Plunger, RebindControls.Plunger},
};
@@ -113,6 +114,8 @@ void options::InitPrimary()
Options.DebugOverlayCollisionMask = get_int("Debug Overlay Collision Mask", true);
Options.DebugOverlaySprites = get_int("Debug Overlay Sprites", true);
Options.DebugOverlaySounds = get_int("Debug Overlay Sounds", true);
translations::SetCurrentLanguage(get_string("Language", translations::GetCurrentLanguage()->ShortName).c_str());
Options.FontFileName = get_string("FontFileName", "");
}
void options::InitSecondary()
@@ -160,7 +163,9 @@ void options::uninit()
set_int("Debug Overlay Ball Edges", Options.DebugOverlayBallEdges);
set_int("Debug Overlay Collision Mask", Options.DebugOverlayCollisionMask);
set_int("Debug Overlay Sprites", Options.DebugOverlaySprites);
get_int("Debug Overlay Sounds", Options.DebugOverlaySounds);
set_int("Debug Overlay Sounds", Options.DebugOverlaySounds);
set_string("Language", translations::GetCurrentLanguage()->ShortName);
set_string("FontFileName", Options.FontFileName.c_str());
}
@@ -339,18 +344,16 @@ void options::RenderControlDialog()
return;
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2{550, 450});
if (ImGui::Begin("3D Pinball: Player Controls", &ShowDialog))
if (ImGui::Begin(pinball::get_rc_string(Msg::KEYMAPPER_Caption), &ShowDialog))
{
ImGui::TextUnformatted("Instructions");
ImGui::TextUnformatted(pinball::get_rc_string(Msg::KEYMAPPER_Groupbox2));
ImGui::Separator();
ImGui::TextWrapped(
"To change game controls, click the control button, press the new key, and then choose OK.");
ImGui::TextWrapped(
"To restore 3D Pinball to its original settings, choose Default, and then choose OK.");
ImGui::TextWrapped("%s", pinball::get_rc_string(Msg::KEYMAPPER_Help1));
ImGui::TextWrapped("%s", pinball::get_rc_string(Msg::KEYMAPPER_Help2));
ImGui::Spacing();
ImGui::TextUnformatted("Control Options");
ImGui::TextUnformatted(pinball::get_rc_string(Msg::KEYMAPPER_Groupbox1));
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2{5, 10});
if (ImGui::BeginTable("Controls", 4, ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Borders))
@@ -366,7 +369,7 @@ void options::RenderControlDialog()
{
ImGui::TableNextColumn();
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{0.5, 0, 0, 1});
if (ImGui::Button(row.Name))
if (ImGui::Button(pinball::get_rc_string(row.NameStringId)))
{
for (auto i = 0u; i <= 2; i++)
row.Option[i] = {};
@@ -419,20 +422,20 @@ void options::RenderControlDialog()
ImGui::PopStyleVar();
ImGui::Spacing();
if (ImGui::Button("OK"))
if (ImGui::Button(pinball::get_rc_string(Msg::KEYMAPPER_Ok)))
{
Options.Key = RebindControls;
ShowDialog = false;
}
ImGui::SameLine();
if (ImGui::Button("Cancel"))
if (ImGui::Button(pinball::get_rc_string(Msg::KEYMAPPER_Cancel)))
{
ShowDialog = false;
}
ImGui::SameLine();
if (ImGui::Button("Default"))
if (ImGui::Button(pinball::get_rc_string(Msg::KEYMAPPER_Default)))
{
RebindControls = Options.KeyDft;
ControlWaitingForInput = nullptr;