LocalizationSystem
Lens Studio v2.0.0+
Inherits from ScriptObject
Description
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.
Methods
getDateAndTimeFormatted(Date date)
: String
Returns a localized string for the date and time of the passed in Date
object.
Example: “Jan 1, 2019 at 12:34 AM”
getDateFormatted(Date date)
: String
Returns a localized string for the date of the passed in Date
object.
Example: “Jan 1, 2019”
getDateShortFormatted(Date date)
: String
Returns a short, localized string for the date of the passed in Date
object.
Example: “1/1/19”
getDayOfWeek(Date date)
: String
Returns a localized string for the day of the week of the passed in Date
object.
Example: “Tuesday”
getFormattedDistanceFromMeters(Number meters)
: String
Returns a localized, formatted string representation of the distance in meters passed in.
Example: “39.4 in” (from 1 passed in)
getFormattedNumber(Number number)
: String
Returns a localized, formatted string representation of the number passed in.
Example: “1,234” (from 1234 passed in)
getFormattedSeconds(Number seconds)
: String
Returns a localized, formatted string representing the number of seconds passed in.
Example: “2:06” (from 126 passed in)
getFormattedTemperatureFromCelsius(Number temperature)
: String
Returns a localized, formatted string representation of the celsius temperature passed in.
Example: “32°F” (from 0 passed in)
getFormattedTemperatureFromFahrenheit(Number temperature)
: String
Returns a localized, formatted string representation of the fahrenheit temperature passed in.
Example: “32°F” (from 32 passed in)
getLanguage()
: String
Returns the language code of the language being used on the device.
Example: “en” (for English)
getMonth(Date date)
: String
Returns a localized string for the month of the passed in Date
object.
Example: “January”
getTimeFormatted(Date date)
: String
Returns a localized string for the time of the passed in Date
object.
Example: “12:34 AM”
Inherited Methods
getTypeName()
: String
Returns the name of this object’s type.
isOfType(String type)
: Boolean
Returns true if the object matches or derives from the passed in type.
Examples
var currentDate = new Date();
print("Today is: " + global.localizationSystem.getDayOfWeek(currentDate));
print("The current time is: " + global.localizationSystem.getTimeFormatted(currentDate));
var tomorrow = new Date();
tomorrow.setDate(currentDate.getDate()+1);
print("Tomorrow's date is: " + global.localizationSystem.getDateFormatted(tomorrow));
Still Looking for help?
Visit Support