-
Notifications
You must be signed in to change notification settings - Fork 0
i18n
Asterios Raptis edited this page Mar 27, 2026
·
1 revision
PluginForge supports multilingual strings loaded from YAML files.
Create language files under config/i18n/:
# config/i18n/en.yaml
app:
title: "My Application"
subtitle: "Plugin-powered"
plugins:
export:
label: "Export"
description: "Export documents"
common:
save: "Save"
cancel: "Cancel"
delete: "Delete"# config/i18n/de.yaml
app:
title: "Meine Anwendung"
subtitle: "Plugin-basiert"
plugins:
export:
label: "Export"
description: "Dokumente exportieren"
common:
save: "Speichern"
cancel: "Abbrechen"
delete: "Loeschen"pm = PluginManager("config/app.yaml")
# Use default language (from app config)
pm.get_text("common.save") # "Speichern" (if default_language: "de")
# Specify language explicitly
pm.get_text("common.save", "en") # "Save"
pm.get_text("common.save", "de") # "Speichern"
# Nested keys with dot notation
pm.get_text("plugins.export.label", "en") # "Export"Set in config/app.yaml:
app:
default_language: "de"If not set, defaults to "en".
- Look up key in the requested language
- If not found, look up in the default language
- If still not found, return the key itself
# Key exists in "en" but not in "fr"
pm.get_text("common.save", "fr") # Falls back to "en" -> "Save"
# Key does not exist at all
pm.get_text("nonexistent.key") # Returns "nonexistent.key"Language files are loaded lazily on first access and cached. Subsequent calls for the same language do not re-read the file.
from pluginforge.i18n import I18n
i18n = I18n("config", default_lang="de")
i18n.get_text("common.save") # "Speichern"
i18n.get_text("common.save", "en") # "Save"