LocalizationsAsset
ClassAsset that provides the necessary localized text for your Lens.
- Available on all platforms
Since Lens Scripting v152
Index
Properties
Methods
Remarks
The asset refers to a folder containing files for each language that you’ve translated your texts to.
The Lens will automatically use the correct localized string provided by a Localizations Asset based on the Snapchatter's device language.
Extends
Properties
name
name:
string
The name of the Asset in Lens Studio.
Default Value
""
Inherited from
uniqueIdentifier
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
Methods
getTypeName()
staticgetTypeName():TypeName<LocalizationsAsset>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<LocalizationsAsset>
Since
Lens Scripting Version 152
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
localize()
localize(
key):string
Exposes user data
Returns the localized string for the given localization key, resolved against the user's device language using only the key/value entries stored in this asset.
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
string
Remarks
The lookup walks the ordered language preferences reported by the LocalizationSystem (for example
"en"), returning the first entry this asset has for one of them. When a preference is region-specific (for
example "es-AR") and this asset has no entry for that exact language, the general language ("es") is used as
a fallback. If the key is not present in this asset, or the asset has no entry for any preferred language, the
key is returned unchanged.
Since
Lens Scripting Version 380
Example
//@input Asset.LocalizationsAsset localizations
//@input Component.Text text
script.text.text = script.localizations.localize("@hello_world");
See also
Localization guide.