"""A simple localization manager to handle multi-language text."""
[docs]
class Localization:
"""Manages text strings for different languages."""
def __init__(self):
[docs]
self.strings = {
'en': {
# Main Menu
'game_title': 'Tipping Pigs',
'english_button': 'English',
'german_button': 'Deutsch',
'play_button': 'Play',
'how_to_play_button': 'How to Play',
'instructions_title': 'The Tipping Point',
'instructions_body': (
"Your island is like a giant seesaw in nature.\n"
"Keeping it balanced keeps life healthy.\n\n"
"In the real world, when balance is broken\n"
"— like too many trees being cut down —\n"
"nature can suddenly change forever.\n\n"
"That moment is called a tipping point.\n"
"Once it tips, it’s very hard to go back.\n\n"
"Your job: protect the island,\n"
"and keep its balance safe."
),
# REMOVE the old 'ingame_controls_tip'
# Add new sequential tutorial steps
'tutorial_step_1': "In the instructions we talked about how cutting down too many trees can tip a forest into chaos. In the game, sending pigs away is like giving the seesaw lighter loads—this helps slow down the tipping of your island’s balance.",
'tutorial_step_2': "Now give it a try! Use Left Click or press ‘S’ to send a pig away. Just like restoring a forest’s balance before it tips, taking weight off the island seesaw keeps everything steady.",
'tutorial_step_3': "Remember how we warned that adding too many pigs can tip the balance—like too much heat melting ice or bleaching coral reefs? Use Right Click or ‘A’ to add pigs—but be careful not to go too far.",
'tutorial_step_4': "Just like how a sudden storm or big change can push a natural system past its tipping point, things can get dangerous here too. If you're close to tipping over, press SPACE for an Emergency Feast! It’s your way to quickly restore balance—like a sudden rain that brings life back to a forest at risk.",
'tutorial_next_button': "Next",
'tutorial_done_button': "Got it!",
# Username Input
'enter_name_title': 'Enter a Name',
'difficulty_title': 'Select Difficulty',
'difficulty_easy': 'Easy',
'difficulty_medium': 'Medium',
'difficulty_hard': 'Hard',
'start_instruction': 'Press Enter to Start',
# General UI
'exit_button': 'Exit',
'restart_button': 'Restart',
# HUD Buttons
'send_pig_button': 'Send Pig (S/LMB)',
'feast_button': 'Emergency Feast (Space)',
'add_pigs_button': 'Add Pigs (A/RMB)',
# HUD Info & Popups
'score_label': 'Score: {score}',
'time_label': 'Time: {time}s',
'feast_cd_label': 'Feast CD: {cooldown}s',
'health_label': 'Environment',
'happiness_label': 'Happiness',
'pigs_label': 'Pigs',
'welcome_message': 'Welcome, Rahui! Manage your island wisely.',
'pig_sent_message': 'Pig sent to neighboring island! +50 points',
'add_pigs_message': 'Added {count} new pigs!',
'feast_message': 'Emergency feast! {pigs} pigs slaughtered. +{points} points',
'no_pigs_for_feast': 'No pigs available for feast!',
'feast_cooldown_message': 'Feast cooldown: {cooldown}s remaining',
# Game State Messages
'paused_title': 'PAUSED',
'resume_instruction': 'Press E to resume',
'game_over_title': 'GAME OVER',
'final_score_label': 'Final Score: {score}',
'restart_instruction': 'Press R to restart.',
'ecosystem_collapsed_message': 'Ecosystem collapsed! Final Score: {score}. Press R to restart.',
'time_up_message': 'Game Over! Final Score: {score}. Press R to restart.',
'critical_warning': 'CRITICAL: Island ecosystem collapsing!',
'heavy_warning': 'WARNING: Heavy environmental degradation!',
# Game Over Performance
'env_perf_excellent': 'The island ecosystem is pristine.',
'env_perf_good': 'The island shows signs of environmental strain.',
'env_perf_bad': 'The environment has been severely damaged.',
'env_perf_disaster': 'The ecosystem has completely collapsed.',
'hap_perf_ecstatic': 'The villagers are thriving and joyful.',
'hap_perf_content': 'The villagers are content with their lives.',
'hap_perf_unhappy': 'The villagers are unhappy and struggling.',
'hap_perf_miserable': 'The villagers are living in misery.',
# Graph
'stability_graph_title': 'Ecosystem',
'high_scores_title': 'High Scores',
'happiness_graph_title': 'Happiness',
# Win/Loss Messages
'win_message': "Congratulations! You kept the island in balance!",
'lose_message': "Oh no! The island tipped over. Try again to keep it balanced."
},
'de': {
# Main Menu
'game_title': 'Tipping-Pigs',
'english_button': 'English',
'german_button': 'Deutsch',
'play_button': 'Spielen',
'how_to_play_button': 'Anleitung',
'instructions_title': 'Der Kipppunkt',
'instructions_body': (
"Deine Insel ist wie eine große Wippe in der Natur.\n"
"Nur im Gleichgewicht bleibt das Leben gesund.\n\n"
"In der echten Welt, wenn das Gleichgewicht bricht\n"
"— zum Beispiel durch zu viele gefällte Bäume —\n"
"kann sich die Natur plötzlich für immer verändern.\n\n"
"Das nennt man einen Kipppunkt.\n"
"Einmal gekippt, ist es schwer zurückzukehren.\n\n"
"Deine Aufgabe: Beschütze die Insel\n"
"und halte ihr Gleichgewicht."
),
# REMOVE the old 'ingame_controls_tip' for German
# Add new sequential tutorial steps for German
'tutorial_step_1': "In der Anleitung haben wir erklärt, wie zu viele gefällte Bäume einen Wald ins Chaos stürzen können. Im Spiel ist Schweine wegschicken wie das Entfernen von Gewicht—das verlangsamt das Kippen deiner Insel.",
'tutorial_step_2': "Probier es jetzt aus! Mit Linksklick oder 'S' schickst du ein Schwein weg. So wie ein Wald dringend Ruhe zum Erholen braucht, entlastet dein Handeln die Insel und hilft, das Gleichgewicht zu bewahren.",
'tutorial_step_3': "Erinnere dich daran, wie zu viele Schweine das Gleichgewicht kippen lassen—ähnlich wie zu warme Meere Korallen bleichen. Mit Rechtsklick oder 'A' fügst du Schweine hinzu—aber achte darauf, nicht zu übertreiben.",
'tutorial_step_4': "So wie ein plötzlicher Sturm ein natürliches Gleichgewicht stören kann, kann auch dein Spiel gefährlich werden. Wenn du kurz vorm Kippen bist—drücke LEERTASTE für ein Notfall-Festmahl! Das bringt schnell Balance zurück, so wie ein unerwarteter Regen einen bedrohten Wald retten kann.",
'tutorial_next_button': "Weiter",
'tutorial_done_button': "Verstanden!",
# Username Input
'enter_name_title': 'Gib einen Namen ein',
'difficulty_title': 'Schwierigkeit wählen',
'difficulty_easy': 'Einfach',
'difficulty_medium': 'Mittel',
'difficulty_hard': 'Schwer',
'start_instruction': 'Drücke Enter zum Starten',
# General UI
'exit_button': 'Ende',
'restart_button': 'Neustart',
# HUD Buttons
'send_pig_button': 'Schwein (S/LMB)',
'feast_button': 'Notfall-Festmahl (Leertaste)',
'add_pigs_button': 'Schweine (A/RMB)',
# HUD Info & Popups
'score_label': 'Punkte: {score}',
'time_label': 'Zeit: {time}s',
'feast_cd_label': 'Festmahl CD: {cooldown}s',
'health_label': 'Umwelt',
'happiness_label': 'Zufriedenheit',
'pigs_label': 'Schweine',
'welcome_message': 'Willkommen, Rahui! Verwalte deine Insel weise.',
'pig_sent_message': 'Schwein zur Nachbarinsel geschickt! +50 Punkte',
'add_pigs_message': '{count} neue Schweine hinzugefügt!',
'feast_message': 'Notfall-Festmahl! {pigs} Schweine geschlachtet. +{points} Punkte',
'no_pigs_for_feast': 'Keine Schweine für Festmahl verfügbar!',
'feast_cooldown_message': 'Festmahl erst in {cooldown}s möglich',
# Game State Messages
'paused_title': 'PAUSE',
'resume_instruction': 'Drücke E zum Fortsetzen',
'game_over_title': 'SPIEL VORBEI',
'final_score_label': 'Endstand: {score}',
'restart_instruction': 'Drücke R für Neustart.',
'ecosystem_collapsed_message': 'Ökosystem zusammengebrochen! Endstand: {score}. Drücke R für Neustart.',
'time_up_message': 'Spiel vorbei! Endstand: {score}. Drücke R für Neustart.',
'critical_warning': 'KRITISCH: Inselökosystem bricht zusammen!',
'heavy_warning': 'WARNUNG: Starke Umweltzerstörung!',
# Game Over Performance
'env_perf_excellent': 'Das Ökosystem der Insel ist unberührt.',
'env_perf_good': 'Die Insel zeigt Anzeichen von Umweltbelastung.',
'env_perf_bad': 'Die Umwelt wurde schwer beschädigt.',
'env_perf_disaster': 'Das Ökosystem ist vollständig zusammengebrochen.',
'hap_perf_ecstatic': 'Die Dorfbewohner sind überglücklich und gedeihen.',
'hap_perf_content': 'Die Dorfbewohner sind mit ihrem Leben zufrieden.',
'hap_perf_unhappy': 'Die Dorfbewohner sind unglücklich und haben zu kämpfen.',
'hap_perf_miserable': 'Die Dorfbewohner leben im Elend.',
# Graph
'stability_graph_title': 'Ökosystem',
'high_scores_title': 'High Scores',
'happiness_graph_title': 'Zufriedenheit',
# Win/Loss Messages
'win_message': "Glückwunsch! Du hast die Insel im Gleichgewicht gehalten!",
'lose_message': "Oh nein! Die Insel ist gekippt. Versuche es noch einmal."
}
}
[docs]
def set_language(self, lang):
"""Sets the active language."""
if lang in self.strings:
self.language = lang
else:
self.language = 'en'
[docs]
def get(self, key, **kwargs):
"""Gets a formatted string for the current language."""
text_template = self.strings[self.language].get(key, f"<{key}>")
return text_template.format(**kwargs)
# Create a single instance to be used throughout the game
[docs]
localization_manager = Localization()