Method GetStringTableCollections
GetStringTableCollections()
Returns all StringTableCollection that are in the project.
Declaration
public static ReadOnlyCollection<StringTableCollection> GetStringTableCollections()
Returns
Type | Description |
---|---|
ReadOnlyCollection<StringTableCollection> |
Examples
This example shows how to print out the contents of all the StringTableCollection in the project.
[MenuItem("Localization Samples/Print All String Table Collection Contents")]
public static void PrintStringTableCollectionContents()
{
// This example prints out the contents of every String Table Collection
var stringBuilder = new StringBuilder();
foreach (var stringTableCollection in LocalizationEditorSettings.GetStringTableCollections())
{
stringBuilder.AppendLine($"String Table Collection Name: {stringTableCollection.TableCollectionName}");
foreach (var stringTable in stringTableCollection.StringTables)
{
stringBuilder.AppendLine($"\tTable {stringTable.LocaleIdentifier}");
foreach (var stringTableValue in stringTable.Values)
{
stringBuilder.AppendLine($"\t\t{stringTableValue.Key} - {stringTableValue.LocalizedValue}");
if (stringTableValue.MetadataEntries.Count > 0)
{
foreach (var metadataEntry in stringTableValue.MetadataEntries)
{
stringBuilder.AppendLine($"\t\t\t{metadataEntry}");
}
}
}
}
}
Debug.Log(stringBuilder.ToString());
}
This example adds missing tables for locales in the project.
[MenuItem("Localization/Add Missing Tables")]
public static void AddMissingTables()
{
foreach (var stringTableCollection in LocalizationEditorSettings.GetStringTableCollections())
{
foreach (var locale in LocalizationEditorSettings.GetLocales())
{
var table = stringTableCollection.GetTable(locale.Identifier);
if (table == null)
{
table = stringTableCollection.AddNewTable(locale.Identifier);
}
}
}
}