From 8c49524aa33e47796e40de1d07ad0e4d86fff495 Mon Sep 17 00:00:00 2001 From: obligaron Date: Thu, 30 Mar 2023 19:18:54 +0200 Subject: [PATCH] GenerateMagicItemName make translation configurable --- Source/items.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index 50dbb1816..d5a6359fb 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1154,17 +1154,17 @@ void GetStaffPower(const Player &player, Item &item, int lvl, SpellID bs, bool o CalcItemValue(item); } -std::string GenerateMagicItemName(const string_view &baseNamel, const PLStruct *pPrefix, const PLStruct *pSufix) +std::string GenerateMagicItemName(const string_view &baseNamel, const PLStruct *pPrefix, const PLStruct *pSufix, bool translate) { if (pPrefix != nullptr && pSufix != nullptr) { - string_view fmt = _(/* TRANSLATORS: Constructs item names. Format: {Prefix} {Item} of {Suffix}. Example: King's Long Sword of the Whale */ "{0} {1} of {2}"); - return fmt::format(fmt::runtime(fmt), _(pPrefix->PLName), baseNamel, _(pSufix->PLName)); + string_view fmt = translate ? _(/* TRANSLATORS: Constructs item names. Format: {Prefix} {Item} of {Suffix}. Example: King's Long Sword of the Whale */ "{0} {1} of {2}") : "{0} {1} of {2}"; + return fmt::format(fmt::runtime(fmt), translate ? _(pPrefix->PLName) : pPrefix->PLName, baseNamel, translate ? _(pSufix->PLName) : pSufix->PLName); } else if (pPrefix != nullptr) { - string_view fmt = _(/* TRANSLATORS: Constructs item names. Format: {Prefix} {Item}. Example: King's Long Sword */ "{0} {1}"); - return fmt::format(fmt::runtime(fmt), _(pPrefix->PLName), baseNamel); + string_view fmt = translate ? _(/* TRANSLATORS: Constructs item names. Format: {Prefix} {Item}. Example: King's Long Sword */ "{0} {1}") : "{0} {1}"; + return fmt::format(fmt::runtime(fmt), translate ? _(pPrefix->PLName) : pPrefix->PLName, baseNamel); } else if (pSufix != nullptr) { - string_view fmt = _(/* TRANSLATORS: Constructs item names. Format: {Item} of {Suffix}. Example: Long Sword of the Whale */ "{0} of {1}"); - return fmt::format(fmt::runtime(fmt), baseNamel, _(pSufix->PLName)); + string_view fmt = translate ? _(/* TRANSLATORS: Constructs item names. Format: {Item} of {Suffix}. Example: Long Sword of the Whale */ "{0} of {1}") : "{0} of {1}"; + return fmt::format(fmt::runtime(fmt), baseNamel, translate ? _(pSufix->PLName) : pSufix->PLName); } return std::string(baseNamel); @@ -1251,9 +1251,9 @@ void GetItemPower(const Player &player, Item &item, int minlvl, int maxlvl, Affi pSufix = &suffix; }); - CopyUtf8(item._iIName, GenerateMagicItemName(item._iName, pPrefix, pSufix), sizeof(item._iIName)); + CopyUtf8(item._iIName, GenerateMagicItemName(item._iName, pPrefix, pSufix, true), sizeof(item._iIName)); if (!StringInPanel(item._iIName)) { - CopyUtf8(item._iIName, GenerateMagicItemName(_(AllItemsList[item.IDidx].iSName), pPrefix, pSufix), sizeof(item._iIName)); + CopyUtf8(item._iIName, GenerateMagicItemName(_(AllItemsList[item.IDidx].iSName), pPrefix, pSufix, true), sizeof(item._iIName)); } if (pPrefix != nullptr || pSufix != nullptr) CalcItemValue(item);