Class StringTableCollection
Provides methods for managing multiple StringTable in the Editor.
Inherited Members
Namespace: UnityEditor.Localization
Syntax
public class StringTableCollection : LocalizationTableCollection, ISerializationCallbackReceiver
Properties
DefaultGroupName
The default value to use for Group.
Declaration
protected override string DefaultGroupName { get; }
Property Value
Type | Description |
---|---|
String |
Overrides
RequiredExtensionAttribute
The required attribute for an extension to be added to this collection through the Editor.
Declaration
protected override Type RequiredExtensionAttribute { get; }
Property Value
Type | Description |
---|---|
Type |
Overrides
StringTables
A helper property which is the contents of Tables loaded and cast to StringTable.
Declaration
public virtual ReadOnlyCollection<StringTable> StringTables { get; }
Property Value
Type | Description |
---|---|
ReadOnlyCollection<StringTable> |
TableType
The type of table stored in the collection.
Declaration
protected override Type TableType { get; }
Property Value
Type | Description |
---|---|
Type |
Overrides
Methods
GenerateCharacterSet(LocaleIdentifier[])
Returns a string that contains all the unique characters that are used for all localized values in the tables that belong to the supplied LocaleIdentifier's. This will also include Smart String entries but will only consider the UnityEngine.Localization.SmartFormat.Core.Parsing.LiteralText values, it will not consider UnityEngine.Localization.SmartFormat.Core.Parsing.Placeholder values.
Declaration
public string GenerateCharacterSet(params LocaleIdentifier[] localeIdentifiers)
Parameters
Type | Name | Description |
---|---|---|
LocaleIdentifier[] | localeIdentifiers | The tables to be included. |
Returns
Type | Description |
---|---|
String | All distinct characters or an empty string if no tables or entries. |
GetRowEnumerator()
Returns an enumerator that can be used to step through each key and its localized values, such as in a foreach loop. Internally SharedTableData and StringTable's are separate assets with their own internal list of values. This means that when iterating through each key a lookup must be made in each table in order to retrieve the localized value, this can become slow when dealing with a large number of tables and entries. GetRowEnumerator improves this process by first sorting the multiple internal lists and then stepping through each conceptual row at a time. It handles missing keys and table entries and provides a more efficient and faster way to iterate through the tables.
Declaration
public IEnumerable<LocalizationTableCollection.Row<StringTableEntry>> GetRowEnumerator()
Returns
Type | Description |
---|---|
IEnumerable<LocalizationTableCollection.Row<StringTableEntry>> |
Examples
This example shows how a StringTableCollection could be exported as CSV.
[MenuItem("CONTEXT/StringTableCollection/Print CSV")]
public static void CreateCSV(MenuCommand command)
{
var collection = command.context as StringTableCollection;
StringBuilder sb = new StringBuilder();
// Header
sb.Append("Key,");
foreach (var table in collection.StringTables)
{
sb.Append(table.LocaleIdentifier);
sb.Append(",");
}
sb.Append("\n");
// Add each row
foreach (var row in collection.GetRowEnumerator())
{
// Key column
sb.Append(row.KeyEntry.Key);
sb.Append(",");
foreach (var tableEntry in row.TableEntries)
{
// The table entry will be null if no entry exists for this key
sb.Append(tableEntry == null ? string.Empty : tableEntry.Value);
sb.Append(",");
}
sb.Append("\n");
}
// Print the contents. You could save it to a file here.
Debug.Log(sb.ToString());
}
GetRowEnumerator(StringTable[])
Declaration
public static IEnumerable<LocalizationTableCollection.Row<StringTableEntry>> GetRowEnumerator(params StringTable[] tables)
Parameters
Type | Name | Description |
---|---|---|
StringTable[] | tables |
Returns
Type | Description |
---|---|
IEnumerable<LocalizationTableCollection.Row<StringTableEntry>> |
RemoveEntry(TableEntryReference)
Removes the entry from the SharedTableData and all tables that are part of this collection.
Declaration
public override void RemoveEntry(TableEntryReference entryReference)
Parameters
Type | Name | Description |
---|---|---|
TableEntryReference | entryReference |