Skip to main content

LocalizationsAsset

Class

Asset that provides the necessary localized text for your Lens.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Since Lens Scripting v152

Index

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

Asset.name


uniqueIdentifier

readonly uniqueIdentifier: string

Since

Lens Scripting Version 176

Inherited from

Asset.uniqueIdentifier

Methods

getTypeName()

static getTypeName(): 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

Asset.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Asset.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

Asset.isOfType


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

ParameterType
otherScriptObject

Returns

boolean

Inherited from

Asset.isSame


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

ParameterType
keystring

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.