Contextual Localization
Details
Contextual localization is a way to access data from Localization Objects when localizing a string.
The concept differs slightly from standard values ($VAL$) that can be injected into the localization string by allowing the localization string
to select which properties to add to the resulting string and where.
When a string is contextually localized with a localization object, then there's one root object (either a Scope or Localization Environment.
In general this object can only be used for two purposes: Accessing other objects and getting the current date.
The documentation for the different localization objects can be found at Localization Objects.
Using a localization object
The localization objects are used with the following syntax: [(Object.)+Property].
(Object.)+ refers to a sequence of at least one object accessor and Property is the property
that is accessed by the last object in the sequence. For example, if the localization string is localized with an Character object
the following queries would get the character's name and the name of the country that the character belongs to [Character.GetName]
and [Character.Owner.GetName], respectively.
Condition in contextual localization
Conditions in contextual localization can be used to check if objects are null or not. The basic syntax for the condition is [(OBJECT ? TRUE_CASE : FALSE_CASE)].
Where:
OBJECTis any object you can use to access a property from (for example,CharacterandCharacter.Ownerare valid objects).TRUE_CASEandFALSE_CASEare what is to be localized ifOBJECTis not null and null, respectively. These can hold one of the following values:'LOC_KEY- A localization key (LOC_KEY, note the prepending'that means that it's a localization key) that will be localized using the same context as the root contextual localization.(OBJECT.)+Property- Standard access of a property from an object (discards the object before the?).(OBJECT.)+stands for a sequence of at least one object, with dots as separators.- (true case only)
.(OBJECT.)*Property- Continue that object sequence from the object before the?.(OBJECT.)*stands for a potentially empty sequence of objects with dots as separators. This is more efficient than the second option since it will not redo the object getters before the?.
Relation to Event Scopes
When a localization string is localized from a scoped context (for example effects or triggers), then the root Scope is created
from the event scope of that context. For example, an effect that creates a trade route between two countries FROM and THIS
could be localized with: LOC_KEY: "Creates a trade route between [FROM.GetName] and [THIS.GetName]". For more information on
how the scope accessors FROM, THIS, PREV and ROOT works on Scope see TODO: Add link.
Documentation of localized objects
In general a scoped context (for example, effects and triggers) are localized using a Scope object based on the scope of that context.
However, there are legacy systems where this may not hold. For other places where localization keys are provided, please see the documentation
for which localization objects that are defined for that context.
Source: Script Concepts Documentation
- Name
- Type
- Script Concept