Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AddStringEntry(string, string, bool?)

Adds or updates a plain string entry for a key.
Read time 1 minuteLast updated 9 days ago

Definition

  • Type: Method
  • Namespace: Unity.Localization
  • Assembly: UnityEngine.LocalizationRuntimeModule
public StringEntry AddStringEntry(string key, string value, bool? isSmart = null)

Parameters

The key text; added to the shared data when new.

value

The localized value to store for this locale.

isSmart

Whether the value is a Smart String, formatted at resolve time; omit it to leave the key's flag unchanged.

Returns

Type

Description

StringEntryThe added or updated entry, or
null
when it cannot be added.

Remarks

Adds the key to ResourceTable.SharedData when it is new, then stores the value for this locale. When an entry already exists for the key, its value is overwritten. When
isSmart
is supplied it is stored on the shared key, so it applies to every locale and can turn an existing key back into a plain string; when it is omitted the key's existing flag is left unchanged. Returns
null
when no shared data is assigned or the key is empty.
Add plain and Smart String entries to a table.

Examples

using Unity.Localization;using UnityEngine;namespace Unity.Localization.Samples{ public class ResourceTableAddStringEntryExample { public void Run() { var shared = ScriptableObject.CreateInstance<SharedTableData>(); var table = ScriptableObject.CreateInstance<ResourceTable>(); table.SharedData = shared; table.LocaleIdentifier = "en"; StringEntry greeting = table.AddStringEntry("Greeting", "Hello"); Debug.Log(greeting.Value); // Hello table.AddStringEntry("Score", "You scored {0}", isSmart: true); } }}