Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substitute In-Game Text with User-Generated Strings #2

Open
TheJabuJabu opened this issue Jan 22, 2025 · 0 comments
Open

Substitute In-Game Text with User-Generated Strings #2

TheJabuJabu opened this issue Jan 22, 2025 · 0 comments
Assignees

Comments

@TheJabuJabu
Copy link
Owner

TheJabuJabu commented Jan 22, 2025

Overview

To enable localization and modding, we need a system that allows user-generated JSON files containing translated or modified strings to replace the corresponding in-game text. This ensures flexibility in localization and supports custom modding efforts while preserving the vanilla game functionality.

Proposed Implementation Steps

  1. JSON Loading System

    • Parse user-provided JSON files at startup or runtime.
    • Define a file structure for the JSON files (e.g., language-specific directories):
      localization/
        en.json
        fr.json
        de.json
      
    • Example JSON format:
      {
        "ID_001": "Welcome to the game!",
        "ID_002": "Press Start to Begin",
        "ID_003": "Game Over"
      }
  2. Key-Based String Mapping

    • Assign unique IDs to all in-game strings during the string extraction phase.
    • Use these IDs to map JSON keys to in-game text.
  3. Runtime String Substitution

    • At runtime, check for the availability of user-provided JSON strings:
      • If the string ID exists in the loaded JSON, substitute the corresponding text.
      • If the string ID is missing, fall back to the vanilla text extracted from the ROM.
  4. Fallback Mechanism

    • Implement a fallback system to ensure missing translations default to a base language (e.g., English).
    • Example logic:
      def get_text(string_id, language):
          if string_id in user_json[language]:
              return user_json[language][string_id]
          elif string_id in user_json['en']:
              return user_json['en'][string_id]
          else:
              return vanilla_strings[string_id]
  5. Dynamic Reloading (Optional)

    • Add support for dynamically reloading JSON files without restarting the game.
    • Useful for testing or hot-swapping language packs.
  6. Integration with In-Game Systems

    • Modify the game’s text-rendering pipeline to retrieve strings using the new substitution system.
    • Ensure compatibility with dynamically constructed or context-sensitive strings (e.g., player names or item counts).

Acceptance Criteria

  • The system can load and parse user-generated JSON files for string substitution.
  • Substituted strings appear correctly in place of in-game text, with fallback to vanilla strings for missing entries.
  • The solution supports runtime changes (optional) and partial translations.
  • The implementation does not introduce significant performance issues.

Future Considerations

  • Add support for localization of dynamically constructed strings.
  • Integrate a testing suite to validate JSON structure and detect missing translations.
  • Extend to include texture-based text or other assets requiring localization.
@TheJabuJabu TheJabuJabu converted this from a draft issue Jan 22, 2025
@TheJabuJabu TheJabuJabu moved this from Backlog to Ready in Ship of Harkinian - Localization Jan 22, 2025
@TheJabuJabu TheJabuJabu moved this from Ready to In progress in Ship of Harkinian - Localization Jan 22, 2025
@TheJabuJabu TheJabuJabu moved this from In progress to Ready in Ship of Harkinian - Localization Jan 22, 2025
@TheJabuJabu TheJabuJabu moved this from Ready to In progress in Ship of Harkinian - Localization Jan 22, 2025
@TheJabuJabu TheJabuJabu self-assigned this Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

No branches or pull requests

1 participant