Version: Unity 6.7 Beta (6000.7)
Language : English
Translations
Create and edit table collections

Localization tables

Understand table collections, keys, entries, and metadata.

Tables store translations. Each locale has its own table, and each key has its own entry. A table collection groups the tables for every locale with the shared key registry, so you author everything in one place.

Collection anatomy

A table collection groups shared key data with one table per locale.
A table collection groups shared key data with one table per locale.

A table collection groups three underlying types:

  • SharedTableData is the key registry. It contains every key with its stable ID, its Smart flag, and any shared metadata. All locales share it.
  • ResourceTable holds one locale’s entries. The Player loads only the tables it needs.
  • ResourceTableCollection is the Editor-only asset that ties them together and records which content source serves them.

You can create a collection from the Assets menu or from the Resource Tables window. Refer to Create and edit table collections for more information. Unity keeps the sibling assets in sync when you move, rename, or delete the collection.

Keys and IDs

Every key has a stable numeric ID, assigned by a DistributedUIDGenerator so IDs stay unique across machines. A rename keeps the key’s ID, so references and shipped data keep working.

Scripts refer to an entry through a TableReference and a TableEntryReference. A TableReference selects the collection by name or globally unique identifier (GUID). A TableEntryReference selects the entry by key name or ID. Names read better in code, but GUIDs and IDs survive renames.

Entry types

A key holds one of the following entry types.

Entry type Description
String A text value. The most common type, and supports Smart Strings.
Asset A reference to an asset, one per locale. Common examples are localized textures, audio clips, and fonts.

Each Asset entry also has a per-locale storage mode (Direct or Resources) that decides whether the asset loads with the table or on demand. Refer to Localize assets.

Smart Strings

Each key has a Smart string toggle in the table editor. A smart entry’s value is a Smart String format, evaluated at resolve time with the arguments and variables you pass. The flag lives on the key, so a key uses Smart Strings in every locale or in none. To enable Smart Strings on a key, refer to Make an entry dynamic.

Variants

You can add variant rows to a key, so one entry holds several values chosen at runtime by a selector. A selector inspects the runtime environment, for example the current platform or a value your code supplies, and picks one variant row. A typical use is one value per platform.

Variants are an authoring feature of the Resource Tables window; no public scripting API exposes them. To create variants, refer to Add variants.

Metadata

Entries, keys, tables, and the collection’s shared data can carry metadata: serializable objects implementing IMetadata. The built-in types are:

Metadata Description
Comment A note for translators or teammates.
Exclude entry from player export Unity doesn’t write the entry to generated data files; it ships inside the table asset instead.
Exclude entry from editor export Unity leaves the entry out of files exported for translators.

A variant key is a key with a Variant Selector metadata item attached, and the Add Entry > Variant menu attaches it for you. You don’t normally add this metadata manually. Refer to Variants.

To define your own, implement IMetadata on a serializable class and mark it with MetadataAttribute to control where it can attach.

Additional resources

Translations
Create and edit table collections