Skip to content

Runtime API (EN)

This is the production-facing runtime surface of Hyper PO Localization.

Use This Entry Point

Use HyperPOLocalization for UI/gameplay text lookups:

csharp
using Hyper.POLocalization;

titleLabel.text = HyperPOLocalization.GetString("Quest Title");

Why:

  • It auto-resolves LanguageManager.
  • It provides safe fallback formatting if no manager is active.
  • It keeps your gameplay code decoupled from scene wiring.

Most Used Methods

Singular

csharp
HyperPOLocalization.GetString("Need {0} items", "3");

Use for standard msgid / msgstr entries.

Context

csharp
HyperPOLocalization.GetStringContext("menu", "Open");
HyperPOLocalization.GetStringContext("hud", "Open");

Use when one key has different meanings (msgctxt).

Plural

csharp
HyperPOLocalization.GetPlural(
    "{0} apple in bag",
    "{0} apples in bag",
    appleCount,
    appleCount.ToString());

Use for msgid_plural + msgstr[n].

Plural + Context

csharp
HyperPOLocalization.GetPluralContext(
    "inventory",
    "{0} apple in bag",
    "{0} apples in bag",
    appleCount,
    appleCount.ToString());

Extraction Metadata Attributes

If you use asset-based extraction and want explicit translator metadata, see:

  • Documentation/ExtractionAttributes.md

Runtime State Helpers

csharp
if (!HyperPOLocalization.IsReady)
{
    // Optional fallback UI
}
csharp
LanguageManager manager = HyperPOLocalization.Manager;

Use Manager only when you need explicit language control.

Manual Language Switching

csharp
using Hyper.POLocalization;
using UnityEngine;

public class LanguageSwitcher : MonoBehaviour
{
    [SerializeField] private LanguageManager manager;

    public void SetSpanish()
    {
        bool exactMatch = manager.SetLanguage("es_ES", allowFallback: true, rescan: true);
        Debug.Log($"Active language: {manager.currentLanguage} | Exact match: {exactMatch}");
    }
}

Common calls:

  • SetLanguage(languageCode, allowFallback, rescan)
  • ScanAvailableLanguages()
  • HasLanguage(languageCode)

Runtime File Convention

Default folder:

  • StreamingAssets/Languages

Examples:

  • en_US.po
  • es_ES.po
  • pt_BR.po

Language codes are normalized from - to _ (for example en-US -> en_US).