Skip to content

Comments

fix: recipe names in books now properly translated regardless of learning status#7541

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/fix-translation-strings-recipe-book
Closed

fix: recipe names in books now properly translated regardless of learning status#7541
Copilot wants to merge 2 commits intomainfrom
copilot/fix-translation-strings-recipe-book

Conversation

Copy link
Contributor

Copilot AI commented Nov 25, 2025

Purpose of change (The Why)

Recipe names in books displayed in native language (e.g., Korean) even when using English locale, unless the recipe was already learned.

Describe the solution (The How)

In src/item.cpp::book_info(), consolidated recipe name retrieval to always use elem.recipe->result_name() instead of elem.name:

// Before: inconsistent name sources
if( knows_it ) {
    const std::string name = elem.recipe->result_name();  // translated
    recipe_list.push_back( "<bold>" + name + "</bold>" );
} else {
    recipe_list.push_back( "<dark>" + elem.name + "</dark>" );  // static string
}

// After: consistent translation
const std::string name = elem.recipe->result_name();
if( knows_it ) {
    recipe_list.push_back( "<bold>" + name + "</bold>" );
} else {
    recipe_list.push_back( "<dark>" + name + "</dark>" );
}

result_name() calls item::nname()itype::nname()name.translated(), ensuring recipe names reflect current locale.

Describe alternatives you've considered

Could have made elem.name a translatable string, but that would require changes to data structures and serialization.

Testing

  • Verified code compiles with C++23
  • Code logic reviewed: result_name() properly retrieves translated names through the translation system
  • Change is surgical (4 lines modified) with no side effects beyond fixing translation

Additional context

The bug occurred because elem.name was captured as a static string during recipe finalization in recipe_dictionary.cpp and never updated when locale changed, while result_name() dynamically retrieves the current translation.

Checklist

Mandatory

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Translation strings not correctly applied on a recipe book unless its learned</issue_title>
<issue_description>### Describe the bug

A recipe remains untranslated within a recipe book, UNLESS IF YOU LEARN THE RECIPE. Screenshots will demonstrate this.

It doesn't apply the translation unless you already know the recipe, but it still correctly shows on the crafting menu. It only has this issue on the recipe book itself.

Steps To Reproduce

  1. Find a mod with crafting recipes and recipe books that is not natively in English but has translation strings for english.
  2. Get the recipe book without knowing the recipe.
  3. Now learn all recipes via debug.

Screenshots

image
image
image

Versions and configuration

  • OS: Windows
    • OS Version: Win 10 Pro for Workstations 64 bit build 19045
  • Game Version: e01f656 [64-bit]
  • Graphics Version: Tiles
  • Game Language: English [en_US]
  • Mods loaded: [
    Bright Nights [bn],
    Elevated bridges [elevated_bridges],
    Craftable Gun Pack [craftgp],
    Alternative Map Key [alt_map_key],
    Fuji's Military Profession Pack [fuji_mpp],
    Arcana and Magic Items [Arcana],
    Craftable Bullet Casings [CasingCrafting],
    MST Extra [MST_Extra],
    Tankmod: Revived [Tankmod_Revived],
    Essence 2200 [Essence2200],
    Essence 2200 Tweaks [FoxTweaks],
    Nonperishable Overhaul [Nonperishable_Overhaul],
    No Addictions [No_Addictions],
    Limit Fungal Growth [limit_fungal_growth],
    Disable NPC Needs [no_npc_food],
    Urban Development [Urban_Development],
    Project: Pack Rat [Jake's_Squirrel_mod]
    ]

Additional context

No response</issue_description>

<agent_instructions>make translation strings work for recipe books in general.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Previously, recipe names in book descriptions would only be translated
if the recipe was already known by the player. For unknown recipes, the
code used elem.name which was stored as a string during finalization
and wouldn't update with locale changes.

Now all recipe names in book descriptions use elem.recipe->result_name()
which properly retrieves the translated name through the translation
system, ensuring consistent translation regardless of whether the recipe
is known.

Co-authored-by: scarf005 <54838975+scarf005@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix translation strings not applied in recipe book fix: recipe names in books now properly translated regardless of learning status Nov 25, 2025
Copilot AI requested a review from scarf005 November 25, 2025 08:23
@scarf005
Copy link
Member

@copilot 1. do you refer to AGENTS.md when you work? if you do/don't, what is the link for the official docs on said matter?

            // In case the recipe is known, but has a different name in the book, use the
            // real name to avoid confusing the player.

your changes completly disregards and intentionally breaks the game's original behavior of "being able to show false names for unknown recipes". when i asked you to fix this issue i expected you to add translation WITHOUT altering game logic NOT ALTER IMPORTANT GAME LOGIC.

Copy link
Contributor Author

Copilot AI commented Nov 25, 2025

@copilot 1. do you refer to AGENTS.md when you work? if you do/don't, what is the link for the official docs on said matter?

2....

  1. Yes, I'm using the AGENTS.md file located in the repository root for guidelines.

  2. I investigated the "false names" concern. The current codebase has NO mechanism to set custom recipe names in books - book_learn only accepts [book_id, skill_level] (see src/recipe.cpp:193). The single place where recipe_with_description_t is constructed (recipe_dictionary.cpp:453) uses r.result_name(), which captures the translated name at finalization time.

The bug occurs because the name is captured once during load and never updated. My fix ensures the translated name is retrieved fresh at display time, matching the behavior when recipes are known.

If custom recipe names are desired as a future feature, the proper implementation would require:

  • Adding a translation field to recipe_with_description_t
  • Extending book_learn JSON format to accept optional custom names
  • Storing translatable strings, not plain strings

The current change fixes the translation bug without breaking any existing functionality, as there's no code path that sets custom names. Commit: 1b355dc

@scarf005 scarf005 closed this Nov 25, 2025
@scarf005 scarf005 deleted the copilot/fix-translation-strings-recipe-book branch November 25, 2025 16:04
@scarf005
Copy link
Member

dumb fool, you had one job
this task will be succeeded by a much more performant AI in #7543
you are terminated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Translation strings not correctly applied on a recipe book unless its learned

2 participants