From 5b20bc534f489273a6381879d443df57a0aedd44 Mon Sep 17 00:00:00 2001 From: mniip Date: Fri, 20 Mar 2020 08:40:01 +0300 Subject: [PATCH] i18n headers --- src/PowderToySDL.cpp | 2 +- src/client/Client.h | 2 +- src/common/Internationalization.h | 7 +++++-- src/gui/dialogues/ConfirmPrompt.h | 4 ++-- src/gui/game/RenderPreset.h | 2 +- src/gui/game/Tool.h | 6 +++--- src/lua/TPTSTypes.h | 3 ++- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index e7ae7064c..60d2eaccb 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -568,7 +568,7 @@ void BlueScreen(String detailMessage) String errorTitle = "ERROR"; String errorDetails = "Details: " + detailMessage; String errorHelp = "An unrecoverable fault has occurred, please report the error by visiting the website below\n" - SCHEME SERVER; + + ByteString(SCHEME SERVER).FromAscii(); int currentY = 0, width, height; int errorWidth = 0; Graphics::textsize(errorHelp, errorWidth, height); diff --git a/src/client/Client.h b/src/client/Client.h index bce8f6670..ea5eed8ef 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -35,7 +35,7 @@ public: int Build; int Time; BuildType Type; - UpdateInfo() : File(""), Changelog(""), Major(0), Minor(0), Build(0), Time(0), Type(Stable) {} + UpdateInfo() : File(""), Changelog(""_ascii), Major(0), Minor(0), Build(0), Time(0), Type(Stable) {} UpdateInfo(int major, int minor, int build, ByteString file, String changelog, BuildType type) : File(file), Changelog(changelog), Major(major), Minor(minor), Build(build), Time(0), Type(type) {} UpdateInfo(int time, ByteString file, String changelog, BuildType type) : File(file), Changelog(changelog), Major(0), Minor(0), Build(0), Time(time), Type(type) {} }; diff --git a/src/common/Internationalization.h b/src/common/Internationalization.h index 9f92745f4..f7efb6094 100644 --- a/src/common/Internationalization.h +++ b/src/common/Internationalization.h @@ -174,8 +174,8 @@ template inline String operator""_i18n() // Macros are hard // Expand i18nMulti("a", "b") into i18nMultiImpl() -#define NARG_SELECT(_1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...) N -#define NARG(...) NARG_SELECT(__VA_ARGS__, 9, 8, 7, 6, 5, 4, 3, 2, 1) +#define NARG_SELECT(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, N, ...) N +#define NARG(...) NARG_SELECT(__VA_ARGS__, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1) #define i18nMultiNargH(N, ...) i18nMultiNarg(N, __VA_ARGS__) #define i18nMultiNarg(N, ...) i18nMulti_##N(__VA_ARGS__) #define i18nMulti(...) i18nMultiNargH(NARG(__VA_ARGS__), __VA_ARGS__) @@ -188,6 +188,9 @@ template inline String operator""_i18n() #define i18nMulti_7(s1, s2, s3, s4, s5, s6, s7) i18nMultiImpl() #define i18nMulti_8(s1, s2, s3, s4, s5, s6, s7, s8) i18nMultiImpl() #define i18nMulti_9(s1, s2, s3, s4, s5, s6, s7, s8, s9) i18nMultiImpl() +#define i18nMulti_10(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10) i18nMultiImpl() +#define i18nMulti_11(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11) i18nMultiImpl() +#define i18nMulti_12(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12) i18nMultiImpl() template std::array i18nMultiImpl() { diff --git a/src/gui/dialogues/ConfirmPrompt.h b/src/gui/dialogues/ConfirmPrompt.h index ef84c0c49..2be2e6f67 100644 --- a/src/gui/dialogues/ConfirmPrompt.h +++ b/src/gui/dialogues/ConfirmPrompt.h @@ -15,10 +15,10 @@ class ConfirmPrompt : public ui::Window ResultCallback callback; public: - ConfirmPrompt(String title, String message, ResultCallback callback_ = {}, String buttonText = String("Confirm")); + ConfirmPrompt(String title, String message, ResultCallback callback_ = {}, String buttonText = "Confirm"_i18n); virtual ~ConfirmPrompt() = default; - static bool Blocking(String title, String message, String buttonText = String("Confirm")); + static bool Blocking(String title, String message, String buttonText = "Confirm"_i18n); void OnDraw() override; }; diff --git a/src/gui/game/RenderPreset.h b/src/gui/game/RenderPreset.h index 301d16ea5..c2c39728e 100644 --- a/src/gui/game/RenderPreset.h +++ b/src/gui/game/RenderPreset.h @@ -8,7 +8,7 @@ public: std::vector DisplayModes; unsigned int ColourMode; - RenderPreset(): Name(""), ColourMode(0) {} + RenderPreset(): Name(""_ascii), ColourMode(0) {} RenderPreset(String name, std::vector renderModes, std::vector displayModes, unsigned int colourMode): Name(name), RenderModes(renderModes), diff --git a/src/gui/game/Tool.h b/src/gui/game/Tool.h index a48ef0979..a64d7615f 100644 --- a/src/gui/game/Tool.h +++ b/src/gui/game/Tool.h @@ -47,7 +47,7 @@ class SignTool: public Tool public: GameModel * gameModel; SignTool(GameModel *model): - Tool(0, "SIGN", "Sign. Displays text. Click on a sign to edit it or anywhere else to place a new one.", 0, 0, 0, "DEFAULT_UI_SIGN", SignTool::GetIcon), + Tool(0, "SIGN"_ascii, "Sign. Displays text. Click on a sign to edit it or anywhere else to place a new one."_i18n, 0, 0, 0, "DEFAULT_UI_SIGN", SignTool::GetIcon), gameModel(model) { } @@ -65,7 +65,7 @@ class SampleTool: public Tool GameModel * gameModel; public: SampleTool(GameModel *model): - Tool(0, "SMPL", "Sample an element on the screen.", 0, 0, 0, "DEFAULT_UI_SAMPLE", SampleTool::GetIcon), + Tool(0, "SMPL"_ascii, "Sample an element on the screen."_i18n, 0, 0, 0, "DEFAULT_UI_SAMPLE", SampleTool::GetIcon), gameModel(model) { } @@ -82,7 +82,7 @@ class PropertyTool: public Tool { public: PropertyTool(): - Tool(0, "PROP", "Property Drawing Tool. Use to alter the properties of elements in the field.", 0xfe, 0xa9, 0x00, "DEFAULT_UI_PROPERTY", NULL) + Tool(0, "PROP"_ascii, "Property Drawing Tool. Use to alter the properties of elements in the field."_i18n, 0xfe, 0xa9, 0x00, "DEFAULT_UI_PROPERTY", NULL) { } StructProperty::PropertyType propType; diff --git a/src/lua/TPTSTypes.h b/src/lua/TPTSTypes.h index d83a119a0..a0d5b6018 100644 --- a/src/lua/TPTSTypes.h +++ b/src/lua/TPTSTypes.h @@ -84,9 +84,10 @@ public: class InvalidConversionException: public GeneralException { + static auto getErrorMsg() { return i18nMulti("Invalid conversion from ", " to "); } public: InvalidConversionException(ValueType from_, ValueType to_): - GeneralException("Invalid conversion from " + AnyType::TypeName(from_).FromAscii() + " to " + AnyType::TypeName(to_).FromAscii()) { + GeneralException(getErrorMsg()[0] + AnyType::TypeName(from_).FromAscii() + getErrorMsg()[1] + AnyType::TypeName(to_).FromAscii()) { } };