Localization

    Localization


    Article summary


    title: Localization

    version: 0.15.0
    layout: default
    sdk: manage

    # Localization Module

    Version Localization 0.15.0

    Table of Contents

    Usage

    To use the Localization module, you can import it into your project from the Firebolt SDK:

    import { Localization } from '@firebolt-js/manage-sdk'
    

    Overview

    Methods for accessessing location and language preferences

    Methods

    addAdditionalInfo

    Add any platform-specific localization information in key/value pair

    function addAdditionalInfo(key: string, value: string): Promise<void>
    

    Parameters:

    ParamTypeRequiredDescription
    keystringtrueKey to add additionalInfo
    valuestringtrueValue to be set for additionalInfo

    Promise resolution:

    void
    

    Capabilities:

    RoleCapability
    managesxrn:firebolt:capability:localization:additional-info

    Examples

    Add an additionalInfo for localization

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.addAdditionalInfo("defaultKey", "defaultValue=")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.addAdditionalInfo",
    	"params": {
    		"key": "defaultKey",
    		"value": "defaultValue="
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    additionalInfo

    Get any platform-specific localization information, in an Map<string, string>

    function additionalInfo(): Promise<object>
    

    Promise resolution:

    object
    

    Capabilities:

    RoleCapability
    usesxrn:firebolt:capability:localization:additional-info

    Examples

    Default Example

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.additionalInfo()
        .then(info => {
            console.log(info)
        })
    

    Value of info:

    {}
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.additionalInfo",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": {}
    }
    

    countryCode

    Get the ISO 3166 code for the counrty device is located in

    To get the value of countryCode call the method like this:

    function countryCode(): Promise<string>
    

    Promise resolution:

    type CountryCode = string
    

    Capabilities:

    RoleCapability
    usesxrn:firebolt:capability:localization:country-code

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.countryCode()
        .then(code => {
            console.log(code)
        })
    

    Value of code:

    "US"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.countryCode",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "US"
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.countryCode()
        .then(code => {
            console.log(code)
        })
    

    Value of code:

    "US"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.countryCode",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "UK"
    }
    

    To set the value of countryCode call the method like this:

    function countryCode(value: string): Promise<void>
    

    Parameters:

    ParamTypeRequiredDescription
    valuestringtruethe device country code
    pattern: ^[A-Za-z]{2}$

    Promise resolution:

    null
    

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.countryCode("US")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setCountryCode",
    	"params": {
    		"value": "US"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.countryCode("UK")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setCountryCode",
    	"params": {
    		"value": "UK"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    To subscribe to notifications when the value changes, call the method like this:

    function countryCode(callback: (value) => string): Promise<number>
    

    Promise resolution:

    number
    

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    countryCode(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of code:

    "US"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onCountryCodeChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "US"
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    countryCode(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of code:

    "US"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onCountryCodeChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "UK"
    }
    

    language

    Get the ISO 639 1/2 code for the preferred language

    To get the value of language call the method like this:

    function language(): Promise<string>
    

    Promise resolution:

    type Language = string
    

    Capabilities:

    RoleCapability
    usesxrn:firebolt:capability:localization:language

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.language()
        .then(lang => {
            console.log(lang)
        })
    

    Value of lang:

    "en"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.language",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "en"
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.language()
        .then(lang => {
            console.log(lang)
        })
    

    Value of lang:

    "en"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.language",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "es"
    }
    

    To set the value of language call the method like this:

    function language(value: string): Promise<void>
    

    Parameters:

    ParamTypeRequiredDescription
    valuestringtruethe device language
    pattern: ^[A-Za-z]{2}$

    Promise resolution:

    null
    

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.language("en")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setLanguage",
    	"params": {
    		"value": "en"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.language("es")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setLanguage",
    	"params": {
    		"value": "es"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    To subscribe to notifications when the value changes, call the method like this:

    function language(callback: (value) => string): Promise<number>
    

    Promise resolution:

    number
    

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    language(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of lang:

    "en"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onLanguageChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "en"
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    language(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of lang:

    "en"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onLanguageChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "es"
    }
    

    listen

    To listen to a specific event pass the event name as the first parameter:

    listen(event: string, callback: (data: any) => void): Promise<number>
    

    Parameters:

    ParamTypeRequiredSummary
    eventstringYesThe event to listen for, see Events.
    callbackfunctionYesA function that will be invoked when the event occurs.

    Promise resolution:

    TypeDescription
    numberListener ID to clear the callback method and stop receiving the event, e.g. Localization.clear(id)

    Callback parameters:

    ParamTypeRequiredSummary
    dataanyYesThe event data, which depends on which event is firing, see Events.

    To listen to all events from this module pass only a callback, without specifying an event name:

    listen(callback: (event: string, data: any) => void): Promise<number>
    

    Parameters:

    ParamTypeRequiredSummary
    callbackfunctionYesA function that will be invoked when the event occurs. The event data depends on which event is firing, see Events.

    Callback parameters:

    ParamTypeRequiredSummary
    eventstringYesThe event that has occured listen for, see Events.
    dataanyYesThe event data, which depends on which event is firing, see Events.

    Promise resolution:

    TypeDescription
    numberListener ID to clear the callback method and stop receiving the event, e.g. Localization.clear(id)

    See Listening for events for more information and examples.

    locale

    Get the full BCP 47 code, including script, region, variant, etc., for the preferred langauage/locale

    To get the value of locale call the method like this:

    function locale(): Promise<string>
    

    Promise resolution:

    type Locale = string
    

    Capabilities:

    RoleCapability
    usesxrn:firebolt:capability:localization:locale

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.locale()
        .then(locale => {
            console.log(locale)
        })
    

    Value of locale:

    "en-US"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.locale",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "en-US"
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.locale()
        .then(locale => {
            console.log(locale)
        })
    

    Value of locale:

    "en-US"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.locale",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "es-US"
    }
    

    To set the value of locale call the method like this:

    function locale(value: string): Promise<void>
    

    Parameters:

    ParamTypeRequiredDescription
    valuestringtruethe device locale
    pattern: ^[a-zA-Z]+([a-zA-Z0-9-]*)$

    Promise resolution:

    null
    

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.locale("en-US")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setLocale",
    	"params": {
    		"value": "en-US"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.locale("es-US")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setLocale",
    	"params": {
    		"value": "es-US"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    To subscribe to notifications when the value changes, call the method like this:

    function locale(callback: (value) => string): Promise<number>
    

    Promise resolution:

    number
    

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    locale(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of locale:

    "en-US"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onLocaleChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "en-US"
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    locale(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of locale:

    "en-US"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onLocaleChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "es-US"
    }
    

    locality

    Get the locality/city the device is located in

    To get the value of locality call the method like this:

    function locality(): Promise<string>
    

    Promise resolution:

    type Locality = string
    

    Capabilities:

    RoleCapability
    usesxrn:firebolt:capability:localization:locality

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.locality()
        .then(locality => {
            console.log(locality)
        })
    

    Value of locality:

    "Philadelphia"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.locality",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "Philadelphia"
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.locality()
        .then(locality => {
            console.log(locality)
        })
    

    Value of locality:

    "Philadelphia"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.locality",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "Rockville"
    }
    

    To set the value of locality call the method like this:

    function locality(value: string): Promise<void>
    

    Parameters:

    ParamTypeRequiredDescription
    valuestringtruethe device city

    Promise resolution:

    null
    

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.locality("Philadelphia")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setLocality",
    	"params": {
    		"value": "Philadelphia"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.locality("Rockville")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setLocality",
    	"params": {
    		"value": "Rockville"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    To subscribe to notifications when the value changes, call the method like this:

    function locality(callback: (value) => string): Promise<number>
    

    Promise resolution:

    number
    

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    locality(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of locality:

    "Philadelphia"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onLocalityChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "Philadelphia"
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    locality(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of locality:

    "Philadelphia"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onLocalityChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "Rockville"
    }
    

    once

    To listen to a single instance of a specific event pass the event name as the first parameter:

    once(event: string, callback: (data: any) => void): Promise<number>
    

    The once method will only pass the next instance of this event, and then dicard the listener you provided.

    Parameters:

    ParamTypeRequiredSummary
    eventstringYesThe event to listen for, see Events.
    callbackfunctionYesA function that will be invoked when the event occurs.

    Promise resolution:

    TypeDescription
    numberListener ID to clear the callback method and stop receiving the event, e.g. Localization.clear(id)

    Callback parameters:

    ParamTypeRequiredSummary
    dataanyYesThe event data, which depends on which event is firing, see Events.

    To listen to the next instance only of any events from this module pass only a callback, without specifying an event name:

    once(callback: (event: string, data: any) => void): Promise<number>
    

    Parameters:

    ParamTypeRequiredSummary
    callbackfunctionYesA function that will be invoked when the event occurs. The event data depends on which event is firing, see Events.

    Callback parameters:

    ParamTypeRequiredSummary
    eventstringYesThe event that has occured listen for, see Events.
    dataanyYesThe event data, which depends on which event is firing, see Events.

    Promise resolution:

    TypeDescription
    numberListener ID to clear the callback method and stop receiving the event, e.g. Localization.clear(id)

    See Listening for events for more information and examples.

    postalCode

    Get the postal code the device is located in

    To get the value of postalCode call the method like this:

    function postalCode(): Promise<string>
    

    Promise resolution:

    string
    

    Capabilities:

    RoleCapability
    usesxrn:firebolt:capability:localization:postal-code

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.postalCode()
        .then(postalCode => {
            console.log(postalCode)
        })
    

    Value of postalCode:

    "19103"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.postalCode",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "19103"
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.postalCode()
        .then(postalCode => {
            console.log(postalCode)
        })
    

    Value of postalCode:

    "19103"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.postalCode",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "20850"
    }
    

    To set the value of postalCode call the method like this:

    function postalCode(value: string): Promise<void>
    

    Parameters:

    ParamTypeRequiredDescription
    valuestringtruethe device postal code

    Promise resolution:

    null
    

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.postalCode("19103")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setPostalCode",
    	"params": {
    		"value": "19103"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.postalCode("20850")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setPostalCode",
    	"params": {
    		"value": "20850"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    To subscribe to notifications when the value changes, call the method like this:

    function postalCode(callback: (value) => string): Promise<number>
    

    Promise resolution:

    number
    

    Examples

    Default example #1

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    postalCode(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of postalCode:

    "19103"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onPostalCodeChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "19103"
    }
    

    Default example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    postalCode(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of postalCode:

    "19103"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onPostalCodeChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "20850"
    }
    

    preferredAudioLanguages

    A prioritized list of ISO 639 1/2 codes for the preferred audio languages on this device.

    To get the value of preferredAudioLanguages call the method like this:

    function preferredAudioLanguages(): Promise<string[]>
    

    Promise resolution:

    string[]
    

    Capabilities:

    RoleCapability
    usesxrn:firebolt:capability:localization:language

    Examples

    Default Example

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.preferredAudioLanguages()
        .then(languages => {
            console.log(languages)
        })
    

    Value of languages:

    [
    	"es",
    	"en"
    ]
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.preferredAudioLanguages",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": [
    		"es",
    		"en"
    	]
    }
    

    Default Example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.preferredAudioLanguages()
        .then(languages => {
            console.log(languages)
        })
    

    Value of languages:

    [
    	"es",
    	"en"
    ]
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.preferredAudioLanguages",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": [
    		"en",
    		"es"
    	]
    }
    

    To set the value of preferredAudioLanguages call the method like this:

    function preferredAudioLanguages(value: string[]): Promise<void>
    

    Parameters:

    ParamTypeRequiredDescription
    valuestring[]truethe preferred audio languages

    Promise resolution:

    null
    

    Examples

    Default Example

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.preferredAudioLanguages(["es","en"])
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setPreferredAudioLanguages",
    	"params": {
    		"value": [
    			"es",
    			"en"
    		]
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    Default Example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.preferredAudioLanguages(["en","es"])
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setPreferredAudioLanguages",
    	"params": {
    		"value": [
    			"en",
    			"es"
    		]
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    To subscribe to notifications when the value changes, call the method like this:

    function preferredAudioLanguages(callback: (value) => string[]): Promise<number>
    

    Promise resolution:

    number
    

    Examples

    Default Example

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    preferredAudioLanguages(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of languages:

    [
    	"es",
    	"en"
    ]
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onPreferredAudioLanguagesChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": [
    		"es",
    		"en"
    	]
    }
    

    Default Example #2

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    preferredAudioLanguages(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of languages:

    [
    	"es",
    	"en"
    ]
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onPreferredAudioLanguagesChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": [
    		"en",
    		"es"
    	]
    }
    

    removeAdditionalInfo

    Remove any platform-specific localization information from map

    function removeAdditionalInfo(key: string): Promise<void>
    

    Parameters:

    ParamTypeRequiredDescription
    keystringtrueKey to remove additionalInfo

    Promise resolution:

    void
    

    Capabilities:

    RoleCapability
    managesxrn:firebolt:capability:localization:additional-info

    Examples

    Remove an additionalInfo for localization

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.removeAdditionalInfo("defaultKey")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.removeAdditionalInfo",
    	"params": {
    		"key": "defaultKey"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    timeZone

    Set the IANA timezone for the device

    To get the value of timeZone call the method like this:

    function timeZone(): Promise<string>
    

    Promise resolution:

    type TimeZone = string
    

    Capabilities:

    RoleCapability
    usesxrn:firebolt:capability:localization:time-zone

    Examples

    Default Example

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.timeZone()
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    "America/New_York"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.timeZone",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "America/New_York"
    }
    

    Additional Example

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.timeZone()
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    "America/New_York"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.timeZone",
    	"params": {}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "America/Los_Angeles"
    }
    

    To set the value of timeZone call the method like this:

    function timeZone(value: string): Promise<void>
    

    Parameters:

    ParamTypeRequiredDescription
    valuestringtrue
    pattern: ^[-+_/ A-Za-z 0-9]*$

    Promise resolution:

    null
    

    Examples

    Default Example

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.timeZone("America/New_York")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setTimeZone",
    	"params": {
    		"value": "America/New_York"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    Additional Example

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    Localization.timeZone("America/Los_Angeles")
        .then(result => {
            console.log(result)
        })
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.setTimeZone",
    	"params": {
    		"value": "America/Los_Angeles"
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": null
    }
    

    To subscribe to notifications when the value changes, call the method like this:

    function timeZone(callback: (value) => string): Promise<number>
    

    Promise resolution:

    number
    

    Examples

    Default Example

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    timeZone(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of result:

    "America/New_York"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onTimeZoneChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "America/New_York"
    }
    

    Additional Example

    JavaScript:

    import { Localization } from '@firebolt-js/manage-sdk'
    
    timeZone(value => {
      console.log(value)
    }).then(listenerId => {
      console.log(listenerId)
    })
    

    Value of result:

    "America/New_York"
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Localization.onTimeZoneChanged",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": "America/Los_Angeles"
    }
    

    Events

    countryCodeChanged

    See: countryCode

    languageChanged

    See: language

    localeChanged

    See: locale

    localityChanged

    See: locality

    postalCodeChanged

    See: postalCode

    preferredAudioLanguagesChanged

    See: preferredAudioLanguages

    timeZoneChanged

    See: timeZone


    Was this article helpful?

    What's Next