Lens Scripting API

    Class LocalizationSystem

    Helps convert data types to localized string representations. Accessible through global.localizationSystem.

    Note that formatted or localized strings may appear differently to users depending on their region. The example results given here are representative of a user in the United States, but may appear differently for users in other regions.

    // get today date and time
    var currentDate = new Date();
    print("Today is: " + global.localizationSystem.getDayOfWeek(currentDate));
    print("The current time is: " + global.localizationSystem.getTimeFormatted(currentDate));
    // get tomorrow's date
    var tomorrow = new Date();
    tomorrow.setDate(currentDate.getDate()+1);
    print("Tomorrow's date is: " + global.localizationSystem.getDateFormatted(tomorrow));
    // show image based on locale
    /*
    @typedef LanguageTexturePair
    @property {string} language
    @property {Asset.Texture} texture
    */
    //@input Asset.Texture defaultTex

    //@input Component.Image image
    //@input LanguageTexturePair[] pairs

    var lang = global.localizationSystem.getLanguage();
    var lMap = {}

    for (var i = 0; i < script.pairs.length; i++) {
    lMap[script.pairs[i].language] = script.pairs[i].texture;
    }
    if (lMap[lang] != undefined) {
    script.image.mainMaterial.mainPass.baseTex = lMap[lang];
    } else {
    script.image.mainMaterial.mainPass.baseTex = script.defaultTex;
    }

    Hierarchy (View Summary, Expand)

    Index

    Constructors

    Properties

    language: string

    Use this property to set the language. Intended for debugging.

    Methods

    • Returns a localized string for the date and time of the passed in Date object.

      Example: "Jan 1, 2019 at 12:34 AM"

      Parameters

      • date: Date

      Returns string

    • Returns a localized string for the date of the passed in Date object.

      Example: "Jan 1, 2019"

      Parameters

      • date: Date

      Returns string

    • Returns a short, localized string for the date of the passed in Date object.

      Example: "1/1/19"

      Parameters

      • date: Date

      Returns string

    • Returns a localized string for the day of the week of the passed in Date object.

      Example: "Tuesday"

      Parameters

      • date: Date

      Returns string

    • Returns a localized, formatted string representation of the distance in meters passed in.

      Example: "39.4 in" (from 1 passed in)

      Parameters

      • meters: number

      Returns string

    • Returns a localized, formatted string representation of the number passed in.

      Example: "1,234" (from 1234 passed in)

      Parameters

      • number: number

      Returns string

    • Returns a localized, formatted string representing the number of seconds passed in.

      Example: "2:06" (from 126 passed in)

      Parameters

      • seconds: number

      Returns string

    • Returns a localized, formatted string representation of the celsius temperature passed in.

      Example: "32F" (from 0 passed in)

      Parameters

      • temperature: number

      Returns string

    • Returns a localized, formatted string representation of the fahrenheit temperature passed in.

      Example: "32F" (from 32 passed in)

      Parameters

      • temperature: number

      Returns string

    • Exposes User Data

      Returns the language code of the language being used on the device.

      Example: "en" (for English)

      Returns string

    • Returns a localized string for the month of the passed in Date object.

      Example: "January"

      Parameters

      • date: Date

      Returns string

    • Returns a localized string for the time of the passed in Date object.

      Example: "12:34 AM"

      Parameters

      • date: Date

      Returns string

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

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean

    • Exposes User Data

      The method takes a localization key and returns the localized string according to device language. Useful for localizing strings before formatting them and assigning them to Text.

      Parameters

      • key: string

      Returns string

    MMNEPVFCICPMFPCPTTAAATR