Reference API Roblox

Engine API

Website

Related

Reference API Roblox

Translator

The role of a Translator is to manufacture/return strings localized for the viewing player.

This class is not replicated. Its interface does not cross the network boundary.
This class is not creatable. Instances of this class cannot be created with Instance.new.
Tags: [NotCreatable, NotReplicated]

Member index 4

HistoryMember
731LocaleId: string
462FormatByKey(key: string, args: Variant): string
462RobloxOnlyTranslate(context: Instance, text: string): string
462Translate(context: Instance, text: string): string
inherited from Instance
731Archivable: bool
731Capabilities: SecurityCapabilities
731IsInSandbox: bool
731Name: string
731Parent: Instance
731PredictionMode: PredictionMode
731Sandboxed: bool
731UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
707GetDescendants(): Instances
486GetFullName(): string
706GetStyled(name: string, selector: string?): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
698QueryDescendants(selector: string): Instances
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
731children(): Instances
731clone(): Instance
731destroy(): null
731findFirstChild(name: string, recursive: bool = false): Instance
731getChildren(): Instances
731isDescendantOf(ancestor: Instance): bool
731remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
731childAdded(child: Instance)
inherited from Object
731ClassName: string
731className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
731isA(className: string): bool
647Changed(property: string)

Description

The role of a Translator is to manufacture/return strings localized for the viewing player. It can be used to retrieve display-ready localized text from a LocalizationTable. The source of the Translator.LocaleId property, the set of tables it will search, and the order it will search them in depends on which method was used to create the Translator instance.

The input for a Translator is the original development language string and a context, where all or part of the context can be used to find a more precise/situational translation for the source string.

The Translator can also be used to manufacture translated strings with inserts (data replacements) which may change order based on the target language.

History 13

Members 4

FormatByKey

Parameters (2)
keystring
argsVariant
Returns (1)
string

Returns the localized text string in a LocalizationTable based on its Translator locale, by key. The optional args table is used for filling format parameters in the matching text entry.

Note that this method will throw an error in the following cases:

  • If none of the LocalizationTables available to this Translator include a value for the given key.
  • If the format string for the key uses numbered parameters and args is not an array.
  • If the format string uses named parameters and args is not a table of key-value pairs.
  • If args is missing values for parameters that are used in the matching format string.

See Localize with scripting for more details and usage examples of this function.

History 2

LocaleId

TypeDefault
string

The Roblox locale of the output translated strings from this table, for example "en-us" or "es-es." Defaults to "en-us".

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 6

Tags: [ReadOnly, NotReplicated]

RobloxOnlyTranslate

Parameters (2)
contextInstance
textstring
Returns (1)
string

History 2

Translate

Parameters (2)
contextInstance
textstring
Returns (1)
string

Returns the localized text string in a LocalizationTable based on its Translator locale. This string will be in the context of the provided object, given the provided Source text.

See Localize with scripting for more details and usage examples of this function.

Context Overrides

In some cases, duplicate Source strings may have completely different translations in other languages. For example, the English noun "Screen" can indicate both a computer screen and a window screen, but the Spanish translations are completely different:

ABCDE
KeyContextSourceExamplees
ScreenPantalla
ScreenMosquitero

In these cases, the first argument to this function — a valid in-game Instance — can be used as a "tie breaker" when multiple GUI objects use the same source string. To implement this, specify the "path" to the Instance you'd like to override as the Context value of the translation data:

ABCDE
KeyContextSourceExamplees
workspace.ComputerScreen.SurfaceGui.TextLabelScreenPantalla
ScreenMosquitero

Then, when calling this function in a script, pass the same Instance as the first argument, followed by the Source lookup text as the second argument:

History 2

Settings