LocalizationTable
A LocalizationTable is a database of translations. It contains source strings and translations for various languages.
Memory category | Instances |
---|
Member index 22
Description
A LocalizationTable is a database of translations. It contains source strings and translations for various languages. It is used with the Translator and LocalizationService auto-translator system to control text translations in the game. LocalizationTables are designed to be treated as resources, like a texture or a script. They are not optimized to be modified at runtime. Changing the contents of a table will cause the entire contents of the table to be replicated to all players.
LocalizationTable Entries
Each LocalizationTable contains a set of entries. Each entry contains the translations of the text, along with some special fields:
- Key is an optional unique key for fast hash lookups in code. If it is non-empty it must be unique in the table.
- Source is the original text in the source language that will be used by the LocalizationService automatic text replacement system to match GUI text and render a translation instead. The Source field can be filled by the text capture tools, or can be set manually. For key-based lookups the Source value can be used as a translation for LocalizationTable.SourceLocaleId if the entry doesn't have a translation for that locale. If Source is empty then the entry will not be used by the automatic replacement system.
- Context is the full Instance name for the object that the text appeared on. Context is used for disambiguation by the automatic text replacement system. When multiple matches for the Source are found, the system will pick the best match by matching backwards from the end of the Context string. There are other more robust ways to handle disambiguation available as well, like using multiple tables with GuiBase2d.RootLocalizationTable.
- Example is whatever you want it to be. If the text capture tool guessed some parameters for a string the Example field will contain an example of them used in context.
All of these fields are optional, but at least either Key or Source must be non-empty. No two entries can have the same Key, Source, and Context.
See Translating Dynamic Content for more information.
History 97
- 573 Change ReturnType of SetIsExemptFromUGCAnalytics from void to null
- 573 Change ReturnType of SetEntryValue from void to null
- 573 Change ReturnType of SetEntrySource from void to null
- 573 Change ReturnType of SetEntryKey from void to null
- 573 Change ReturnType of SetEntryExample from void to null
- 573 Change ReturnType of SetEntryContext from void to null
- 573 Change ReturnType of SetEntry from void to null
- 573 Change ReturnType of SetEntries from void to null
- 573 Change ReturnType of SetContents from void to null
- 573 Change ReturnType of RemoveTargetLocale from void to null
- 573 Change ReturnType of RemoveKey from void to null
- 573 Change ReturnType of RemoveEntryValue from void to null
- 573 Change ReturnType of RemoveEntry from void to null
- 553 Change PreferredDescriptor of SetEntry from to SetEntryValue
- 553 Change PreferredDescriptor of SetContents from to SetEntries
- 553 Change PreferredDescriptor of RemoveKey from to RemoveEntry
- 553 Change PreferredDescriptor of GetString from to GetTranslator
- 553 Change PreferredDescriptor of GetContents from to GetEntries
- 553 Change Default of SourceLocaleId from to en-us
- 553 Change Default of from to
- 553 Change PreferredDescriptor of from to RootLocalizationTable
- 553 Add
- 553 Change PreferredDescriptor of from to SourceLocaleId
- 553 Change Default of from to en-us
- 553 Add
- 486 Change ThreadSafety of SourceLocaleId from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 462 Change ThreadSafety of SetIsExemptFromUGCAnalytics from to Unsafe
- 462 Change ThreadSafety of SetEntryValue from to Unsafe
- 462 Change ThreadSafety of SetEntrySource from to Unsafe
- 462 Change ThreadSafety of SetEntryKey from to Unsafe
- 462 Change ThreadSafety of SetEntryExample from to Unsafe
- 462 Change ThreadSafety of SetEntryContext from to Unsafe
- 462 Change ThreadSafety of SetEntry from to Unsafe
- 462 Change ThreadSafety of SetEntries from to Unsafe
- 462 Change ThreadSafety of SetContents from to Unsafe
- 462 Change ThreadSafety of RemoveTargetLocale from to Unsafe
- 462 Change ThreadSafety of RemoveKey from to Unsafe
- 462 Change ThreadSafety of RemoveEntryValue from to Unsafe
- 462 Change ThreadSafety of RemoveEntry from to Unsafe
- 462 Change ThreadSafety of GetTranslator from to Unsafe
- 462 Change ThreadSafety of GetString from to Unsafe
- 462 Change ThreadSafety of GetEntries from to Unsafe
- 462 Change ThreadSafety of GetContents from to Unsafe
- 462 Change ThreadSafety of SourceLocaleId from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 445 Add SetEntry
- 445 Add SetContents
- 445 Add RemoveKey
- 445 Add GetContents
- 445 Add
- 445 Remove SetEntry
- 445 Remove SetContents
- 445 Remove RemoveKey
- 445 Remove GetContents
- 445 Remove
- 337 Add SetIsExemptFromUGCAnalytics
- 329 Change ValueType of from Object to Instance
- 326 Add SetEntryValue
- 326 Add SetEntrySource
- 326 Add SetEntryKey
- 326 Add SetEntryExample
- 326 Add SetEntryContext
- 326 Change Tags of SetEntry from [] to [Deprecated]
- 326 Change Tags of SetContents from [] to [Deprecated]
- 326 Add RemoveTargetLocale
- 326 Change Tags of RemoveKey from [] to [Deprecated]
- 326 Add RemoveEntryValue
- 326 Add RemoveEntry
- 326 Change Tags of GetString from [] to [Deprecated]
- 326 Change Tags of GetContents from [] to [Deprecated]
- 326 Change Tags of from [NotReplicated] to [Hidden, NotReplicated, Deprecated]
- 322 Add SetEntries
- 322 Change Tags of SourceLocaleId from [Hidden] to []
- 322 Change Tags of from [NotReplicated] to [Hidden, NotReplicated, Deprecated]
- 319 Add GetTranslator
- 318 Add SourceLocaleId
- 317 Change Parameters of SetEntry from (key: string, locale: string, text: string) to (key: string, targetLocaleId: string, text: string)
- 317 Change Parameters of GetString from (languageKey: string, expressionKey: string) to (targetLocaleId: string, key: string)
- 307 Change Tags of from [Hidden, NotReplicated] to [NotReplicated]
- 307 Change Tags of from [Hidden, NotReplicated] to [NotReplicated]
- 304 Add SetEntry
- 304 Add SetContents
- 304 Add RemoveKey
- 304 Add GetEntries
- 304 Add GetContents
- 304 Remove
- 295 Change Tags of from [NotReplicated] to [Hidden, NotReplicated]
- 295 Change Tags of from [NotReplicated] to [Hidden, NotReplicated]
- 295 Change Tags of from [] to [Hidden]
- 292 Add GetString
- 292 Add
- 292 Add
- 292 Add
- 292 Add LocalizationTable
Members 22
GetContents
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
string |
Thread safety | Unsafe |
---|
History 6
- 553 Change PreferredDescriptor of GetContents from to GetEntries
- 462 Change ThreadSafety of GetContents from to Unsafe
- 445 Add GetContents
- 445 Remove GetContents
- 326 Change Tags of GetContents from [] to [Deprecated]
- 304 Add GetContents
GetEntries
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Array |
The GetEntries function returns an array of dictionaries contained in a given LocalizationTable, where each dictionary represents an entry of localization data.
To set the entries of a LocalizationTable, you can use LocalizationTable:SetEntries().
Each dictionary in the array contains the following fields:
Index | Type | Description |
---|---|---|
Key | string | A lookup key for this specific entry in the LocalizationTable. |
Source | string | The string used to format the localized string. Used as a lookup if a key is not provided. |
Context | string | An Instance:GetFullName() path to the object that was used to generate the LocalizationTable. Used as a lookup if a key is not provided. |
Example | string | The string used to format the localization. Optional. |
Values | Dictionary | A dictionary of language translations for this localization entry. The keys of this dictionary are locale ids, and the values are strings that are used to apply localization for the language corresponding to the locale id. |
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of GetEntries from to Unsafe
- 304 Add GetEntries
GetString
Parameters (2) | ||
---|---|---|
targetLocaleId | string | |
key | string | |
Returns (1) | ||
string |
The GetString function returns a translation based on the specified language and key.
Thread safety | Unsafe |
---|
History 5
- 553 Change PreferredDescriptor of GetString from to GetTranslator
- 462 Change ThreadSafety of GetString from to Unsafe
- 326 Change Tags of GetString from [] to [Deprecated]
- 317 Change Parameters of GetString from (languageKey: string, expressionKey: string) to (targetLocaleId: string, key: string)
- 292 Add GetString
GetTranslator
Parameters (1) | ||
---|---|---|
localeId | string | |
Returns (1) | ||
Instance |
Returns a Translator for entries in this LocalizationTable, in the specified language. The translator will first search in this table and then look in ancestor tables.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of GetTranslator from to Unsafe
- 319 Add GetTranslator
RemoveEntry
Parameters (3) | ||
---|---|---|
key | string | |
source | string | |
context | string | |
Returns (1) | ||
null |
Removes an entry from the LocalizationTable, using the specified key
,
source
, and context
to narrow down the specific entry to be removed.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of RemoveEntry from void to null
- 462 Change ThreadSafety of RemoveEntry from to Unsafe
- 326 Add RemoveEntry
RemoveEntryValue
Parameters (4) | ||
---|---|---|
key | string | |
source | string | |
context | string | |
localeId | string | |
Returns (1) | ||
null |
Removes a single language translation from the LocalizationTable, using
the provided key
, source
, context
, and localeId
to narrow down the
specific entry to be removed.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of RemoveEntryValue from void to null
- 462 Change ThreadSafety of RemoveEntryValue from to Unsafe
- 326 Add RemoveEntryValue
RemoveKey
Parameters (1) | ||
---|---|---|
key | string | |
Returns (1) | ||
null |
Deprecated in favor of LocalizationTable:RemoveEntry(). Calling RemoveKey is the same as making the following call to RemoveEntry:
1
|
|
Thread safety | Unsafe |
---|
RemoveTargetLocale
Parameters (1) | ||
---|---|---|
localeId | string | |
Returns (1) | ||
null |
Removes all translations from the LocalizationTable with the specified localeId.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of RemoveTargetLocale from void to null
- 462 Change ThreadSafety of RemoveTargetLocale from to Unsafe
- 326 Add RemoveTargetLocale
SetContents
Parameters (1) | ||
---|---|---|
contents | string | |
Returns (1) | ||
null |
The SetContents function sets the contents of the LocalizationTable, via the legacy JSON format.
Thread safety | Unsafe |
---|
History 7
- 573 Change ReturnType of SetContents from void to null
- 553 Change PreferredDescriptor of SetContents from to SetEntries
- 462 Change ThreadSafety of SetContents from to Unsafe
- 445 Add SetContents
- 445 Remove SetContents
- 326 Change Tags of SetContents from [] to [Deprecated]
- 304 Add SetContents
SetEntries
Parameters (1) | ||
---|---|---|
entries | Variant | |
Returns (1) | ||
null |
Sets the contents of the LocalizationTable.
The entries parameter should be an array of dictionaries in the same format as the one returned from the LocalizationTable:GetEntries() function.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of SetEntries from void to null
- 462 Change ThreadSafety of SetEntries from to Unsafe
- 322 Add SetEntries
SetEntry
Parameters (3) | ||
---|---|---|
key | string | |
targetLocaleId | string | |
text | string | |
Returns (1) | ||
null |
Thread safety | Unsafe |
---|
History 8
- 573 Change ReturnType of SetEntry from void to null
- 553 Change PreferredDescriptor of SetEntry from to SetEntryValue
- 462 Change ThreadSafety of SetEntry from to Unsafe
- 445 Add SetEntry
- 445 Remove SetEntry
- 326 Change Tags of SetEntry from [] to [Deprecated]
- 317 Change Parameters of SetEntry from (key: string, locale: string, text: string) to (key: string, targetLocaleId: string, text: string)
- 304 Add SetEntry
SetEntryContext
Parameters (4) | ||
---|---|---|
key | string | |
source | string | |
context | string | |
newContext | string | |
Returns (1) | ||
null |
Sets the Context field of a LocalizationTable entry to newContext
,
using the specified key
, source
, and context
to narrow down the
entry that will have this change applied.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of SetEntryContext from void to null
- 462 Change ThreadSafety of SetEntryContext from to Unsafe
- 326 Add SetEntryContext
SetEntryExample
Parameters (4) | ||
---|---|---|
key | string | |
source | string | |
context | string | |
example | string | |
Returns (1) | ||
null |
Sets the Example field of a LocalizationTable entry to example
,
using the specified key
, source
, and context
to narrow down the
entry that will have this change applied.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of SetEntryExample from void to null
- 462 Change ThreadSafety of SetEntryExample from to Unsafe
- 326 Add SetEntryExample
SetEntryKey
Parameters (4) | ||
---|---|---|
key | string | |
source | string | |
context | string | |
newKey | string | |
Returns (1) | ||
null |
Sets the Key field of a LocalizationTable entry to newKey
, using the
specified key
, source
, and context
to narrow down the entry that
will have this change applied.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of SetEntryKey from void to null
- 462 Change ThreadSafety of SetEntryKey from to Unsafe
- 326 Add SetEntryKey
SetEntrySource
Parameters (4) | ||
---|---|---|
key | string | |
source | string | |
context | string | |
newSource | string | |
Returns (1) | ||
null |
Sets the Source field of a LocalizationTable entry to newSource
,
using the specified key
, source
, and context
to narrow down the
entry that will have this change applied.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of SetEntrySource from void to null
- 462 Change ThreadSafety of SetEntrySource from to Unsafe
- 326 Add SetEntrySource
SetEntryValue
Parameters (5) | ||
---|---|---|
key | string | |
source | string | |
context | string | |
localeId | string | |
text | string | |
Returns (1) | ||
null |
Sets the text of the specified localeId in a LocalizationTable entry,
using the specified key
, source
, and context
to narrow down the
entry that will have this change applied.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of SetEntryValue from void to null
- 462 Change ThreadSafety of SetEntryValue from to Unsafe
- 326 Add SetEntryValue
SetIsExemptFromUGCAnalytics
Parameters (1) | ||
---|---|---|
value | bool | |
Returns (1) | ||
null |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 3
- 573 Change ReturnType of SetIsExemptFromUGCAnalytics from void to null
- 462 Change ThreadSafety of SetIsExemptFromUGCAnalytics from to Unsafe
- 337 Add SetIsExemptFromUGCAnalytics
SourceLocaleId
Type | Default | |
---|---|---|
string | en-us |
The Roblox locale of the input key strings for this table, for example "en-us" or "es-es." This is typically the "development language" of the game. For a Translator that merges multiple LocalizationTable objects, it's the LocaleId of the Default LocalizationTable. Defaults to "en-us".
Thread safety | ReadSafe |
---|---|
Category | Localization |
Loaded/Saved | true |
History 5
- 553 Change Default of SourceLocaleId from to en-us
- 486 Change ThreadSafety of SourceLocaleId from ReadOnly to ReadSafe
- 462 Change ThreadSafety of SourceLocaleId from to ReadOnly
- 322 Change Tags of SourceLocaleId from [Hidden] to []
- 318 Add SourceLocaleId