--- title: "Localization" slug: "100-core-localization" updated: 2025-05-23T20:23:14Z published: 2025-05-23T20:23:14Z canonical: "docs.developer.comcast.com/100-core-localization" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.developer.comcast.com/llms.txt > Use this file to discover all available pages before exploring further. # Localization **Localization Module 1.0.0 | Core SDK** ## Usage To use the Localization module, you can import it into your project from the Firebolt SDK: ``` import { Localization } from '@firebolt-js/sdk' ``` ## Overview Methods for accessessing location and language preferences ## Methods ### additionalInfo Get any platform-specific localization information, in an Map ``` function additionalInfo(): Promise ``` Promise resolution: ``` object ``` Capabilities: | Role | Capability | | --- | --- | | uses | xrn:firebolt:capability:localization:additional-info | #### Examples Default Example JavaScript: ``` import { Localization } from '@firebolt-js/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-1 alpha-2 code for the country device is located in To get the value of `countryCode` call the method like this: ``` function countryCode(): Promise ``` Promise resolution: ``` type CountryCode = string ``` Capabilities: | Role | Capability | | --- | --- | | uses | xrn:firebolt:capability:localization:country-code | #### Examples Default example #1 JavaScript: ``` import { Localization } from '@firebolt-js/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/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 subscribe to notifications when the value changes, call the method like this: ``` function countryCode(callback: (value) => string): Promise ``` Promise resolution: ``` number ``` #### Examples Default example #1 JavaScript: ``` import { Localization } from '@firebolt-js/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/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 ``` Promise resolution: ``` type Language = string ``` Capabilities: | Role | Capability | | --- | --- | | uses | xrn:firebolt:capability:localization:language | #### Examples Default example #1 JavaScript: ``` import { Localization } from '@firebolt-js/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/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 subscribe to notifications when the value changes, call the method like this: ``` function language(callback: (value) => string): Promise ``` Promise resolution: ``` number ``` #### Examples Default example #1 JavaScript: ``` import { Localization } from '@firebolt-js/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/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" } ``` --- ### latlon Get the approximate latitude and longitude coordinates of the device location ``` function latlon(): Promise<[number, number]> ``` Promise resolution: ``` type LatLon = [number, number] ``` Capabilities: | Role | Capability | | --- | --- | | uses | xrn:firebolt:capability:localization:location | #### Examples Default Example JavaScript: ``` import { Localization } from '@firebolt-js/sdk' Localization.latlon() .then(latlong => { console.log(latlong) }) ``` Value of `latlong`: ``` [ 39.9549, 75.1699 ] ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Localization.latlon", "params": {} } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": [ 39.9549, 75.1699 ] } ``` --- ### listen To listen to a specific event pass the event name as the first parameter: ``` listen(event: string, callback: (data: any) => void): Promise ``` Parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `event` | `string` | Yes | The event to listen for, see [Events](/docs/100-core-localization#events). | | *callback* | `function` | Yes | A function that will be invoked when the event occurs. | Promise resolution: | Type | Description | | --- | --- | | `number` | Listener ID to clear the callback method and stop receiving the event, e.g. `Localization.clear(id)` | Callback parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `data` | `any` | Yes | The event data, which depends on which event is firing, see [Events](/docs/100-core-localization#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 ``` Parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | *callback* | `function` | Yes | A function that will be invoked when the event occurs. The event data depends on which event is firing, see [Events](/docs/100-core-localization#events). | Callback parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `event` | `string` | Yes | The event that has occured listen for, see [Events](/docs/100-core-localization#events). | | `data` | `any` | Yes | The event data, which depends on which event is firing, see [Events](/docs/100-core-localization#events). | Promise resolution: | Type | Description | | --- | --- | | `number` | Listener ID to clear the callback method and stop receiving the event, e.g. `Localization.clear(id)` | See [Listening for events](/docs/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 ``` Promise resolution: ``` type Locale = string ``` Capabilities: | Role | Capability | | --- | --- | | uses | xrn:firebolt:capability:localization:locale | #### Examples Default example #1 JavaScript: ``` import { Localization } from '@firebolt-js/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/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 subscribe to notifications when the value changes, call the method like this: ``` function locale(callback: (value) => string): Promise ``` Promise resolution: ``` number ``` #### Examples Default example #1 JavaScript: ``` import { Localization } from '@firebolt-js/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/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 ``` Promise resolution: ``` type Locality = string ``` Capabilities: | Role | Capability | | --- | --- | | uses | xrn:firebolt:capability:localization:locality | #### Examples Default example #1 JavaScript: ``` import { Localization } from '@firebolt-js/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/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 subscribe to notifications when the value changes, call the method like this: ``` function locality(callback: (value) => string): Promise ``` Promise resolution: ``` number ``` #### Examples Default example #1 JavaScript: ``` import { Localization } from '@firebolt-js/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/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 ``` The `once` method will only pass the next instance of this event, and then dicard the listener you provided. Parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `event` | `string` | Yes | The event to listen for, see [Events](/docs/100-core-localization#events). | | *callback* | `function` | Yes | A function that will be invoked when the event occurs. | Promise resolution: | Type | Description | | --- | --- | | `number` | Listener ID to clear the callback method and stop receiving the event, e.g. `Localization.clear(id)` | Callback parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `data` | `any` | Yes | The event data, which depends on which event is firing, see [Events](/docs/100-core-localization#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 ``` Parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | *callback* | `function` | Yes | A function that will be invoked when the event occurs. The event data depends on which event is firing, see [Events](/docs/100-core-localization#events). | Callback parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `event` | `string` | Yes | The event that has occured listen for, see [Events](/docs/100-core-localization#events). | | `data` | `any` | Yes | The event data, which depends on which event is firing, see [Events](/docs/100-core-localization#events). | Promise resolution: | Type | Description | | --- | --- | | `number` | Listener ID to clear the callback method and stop receiving the event, e.g. `Localization.clear(id)` | See [Listening for events](/docs/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 ``` Promise resolution: ``` string ``` Capabilities: | Role | Capability | | --- | --- | | uses | xrn:firebolt:capability:localization:postal-code | #### Examples Default example #1 JavaScript: ``` import { Localization } from '@firebolt-js/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/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 subscribe to notifications when the value changes, call the method like this: ``` function postalCode(callback: (value) => string): Promise ``` Promise resolution: ``` number ``` #### Examples Default example #1 JavaScript: ``` import { Localization } from '@firebolt-js/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/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 ``` Promise resolution: ``` string[] ``` Capabilities: | Role | Capability | | --- | --- | | uses | xrn:firebolt:capability:localization:language | #### Examples Default Example JavaScript: ``` import { Localization } from '@firebolt-js/sdk' Localization.preferredAudioLanguages() .then(languages => { console.log(languages) }) ``` Value of `languages`: ``` [ "spa", "eng" ] ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Localization.preferredAudioLanguages", "params": {} } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": [ "spa", "eng" ] } ``` Default Example #2 JavaScript: ``` import { Localization } from '@firebolt-js/sdk' Localization.preferredAudioLanguages() .then(languages => { console.log(languages) }) ``` Value of `languages`: ``` [ "spa", "eng" ] ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Localization.preferredAudioLanguages", "params": {} } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": [ "eng", "spa" ] } ``` --- To subscribe to notifications when the value changes, call the method like this: ``` function preferredAudioLanguages(callback: (value) => string[]): Promise ``` Promise resolution: ``` number ``` #### Examples Default Example JavaScript: ``` import { Localization } from '@firebolt-js/sdk' preferredAudioLanguages(value => { console.log(value) }).then(listenerId => { console.log(listenerId) }) ``` Value of `languages`: ``` [ "spa", "eng" ] ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Localization.onPreferredAudioLanguagesChanged", "params": { "listen": true } } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": [ "spa", "eng" ] } ``` Default Example #2 JavaScript: ``` import { Localization } from '@firebolt-js/sdk' preferredAudioLanguages(value => { console.log(value) }).then(listenerId => { console.log(listenerId) }) ``` Value of `languages`: ``` [ "spa", "eng" ] ``` **JSON-RPC:** Request: ``` { "jsonrpc": "2.0", "id": 1, "method": "Localization.onPreferredAudioLanguagesChanged", "params": { "listen": true } } ``` Response: ``` { "jsonrpc": "2.0", "id": 1, "result": [ "eng", "spa" ] } ``` --- ## Events ### countryCodeChanged See: [countryCode](/docs/100-core-localization#countrycode) ### languageChanged See: [language](/docs/100-core-localization#language) ### localeChanged See: [locale](/docs/100-core-localization#locale) ### localityChanged See: [locality](/docs/100-core-localization#locality) ### postalCodeChanged See: [postalCode](/docs/100-core-localization#postalcode) ### preferredAudioLanguagesChanged See: [preferredAudioLanguages](/docs/100-core-localization#preferredaudiolanguages) ## Types ### LatLon ``` type LatLon = [number, number] ``` ---