Skip to content

CVR Translatable

Swaps a text string, TextMeshPro text, audio clip, or a visible GameObject based on the player’s GeneralLanguage setting. Subscribes to MetaPort.Instance.settings.settingStringChanged so changes to the language propagate at runtime.

List<ObjectTranslatable_t>. Each entry drives one renderable or audio target. Entry fields:

  • TypeTranslatableType enum: AudioClip, Text, TextMeshPro, GameObject. Selects which of the other fields is used.
  • TranslationsList<Translation_t>. One per language. Each has:
    • Language — ISO 639-1 language code (e.g. en, ja, fr). Default en.
    • Text — string used when Type == Text or TextMeshPro.
    • Clip — audio clip used when Type == AudioClip.
    • Object — GameObject activated when Type == GameObject (others are deactivated).
  • TmpTextTMP_Text target for TextMeshPro.
  • TextUnityEngine.UI.Text target for Text.
  • SourceAudioSource target for AudioClip.
  • FallbackLanguage — ISO code used when no translation matches the user’s current language. Default en.

The component exposes a static Languages dictionary keyed by ISO 639-1 code covering the standard set from ab (Abkhazian) through zu (Zulu). Use any of these codes for the Language field of a translation entry.

On Start, the selected language is read from GeneralLanguage in player settings, then every Translatables entry is updated. Whenever the user changes language in-game, the component re-applies:

  • Text / TextMeshPro — writes the matching translation’s Text to the target.
  • AudioClip — assigns the matching clip to the source (does not call Play).
  • GameObject — activates the matching entry’s GameObject and deactivates all other entries’ GameObjects in the same translatable.

If no entry matches the current language, the FallbackLanguage lookup is used.

CVR-GameFiles/ABI.CCK.Components/CVRTranslatable.cs