Files
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

2.2 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports params output tested tests test_file_path file_path
t function py core 1.0.0 impure def t(key: str, locale: str | None = None, **kwargs) -> str Traduce una clave con dot-path notation al idioma activo. Prioridad: parametro locale > thread-local > default. Soporta interpolacion {variable}. Fallback al locale default si la clave no existe; si tampoco existe, retorna la key.
i18n
translation
locale
dot-path
interpolation
pendiente-usar
false error_go_core
threading
name desc
key Clave de traducción con dot-path notation (ej: 'report.done')
name desc
locale Locale a usar (default: usa locale thread-local)
name desc
kwargs Variables para interpolación en el template
String traducido e interpolado, o la key si no se encuentra traducción true
key existente retorna traduccion
key inexistente retorna la key
interpolacion de variables
dot-path profundo
fallback a locale default
python/functions/core/t_test.py python/functions/core/t.py

Ejemplo

from t import t, _set_translations

translations = {
    "en": {
        "report": {
            "sectionStart": "Generating section: {title}",
            "done": "Done"
        }
    },
    "es": {
        "report": {
            "done": "Listo"
        }
    }
}
_set_translations(translations, default_locale="en")

t("report.sectionStart", locale="en", title="Introduction")
# → "Generating section: Introduction"

t("report.done", locale="es")
# → "Listo"

t("report.sectionStart", locale="es", title="Intro")
# → "Generating section: Intro"  (fallback a en)

t("nonexistent.key", locale="en")
# → "nonexistent.key"

Notas

Lee estado global (modulo-level _translations y _locale_local thread-local), por eso es impura. Configurar con _set_translations() al inicio de la aplicacion y _set_locale() por thread/request. La interpolacion usa str.format(**kwargs) — si hay un placeholder faltante, retorna el string sin interpolar para no romper el flujo. Inspirada conceptualmente en el modulo locale.py de MiroFish (AGPL-3.0); reimplementada desde cero.