--- title: "Localization" slug: "081-core-localization" updated: 2025-05-23T22:34:58Z published: 2025-05-23T22:34:58Z canonical: "docs.developer.comcast.com/081-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 0.8.1 | Core SDK** ## Overview Methods for accessessing location and language preferences ## OpenRPC Firebolt APIs are maintained in the [rdkcentral/firebolt-core-sdk](https://github.com/rdkcentral/firebolt-core-sdk) GitHub repository. You can see this API in the [localization.json](https://github.com/rdkcentral/firebolt-core-sdk/blob/main/src/modules/localization.json) OpenRPC JSON-Schema document. ## Usage To use the Localization module, you can import it into your project from the Firebolt SDK: ``` import { Localization } from '@firebolt-js/sdk' ``` ## Methods ### additionalInfo Get any platform-specific localization information, in an Map ``` function additionalInfo(): Promise ``` Promise resolution: | Type | Description | | --- | --- | | `object` | the 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 code for the counrty device is located in ``` function countryCode(): Promise ``` Promise resolution: | Type | Description | | --- | --- | | `string` | the device country code | **Examples** Default Example 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" } ``` --- ### language Get the ISO 639 1/2 code for the preferred language To get the value, call the method with no parameters: ``` function language(): Promise ``` Promise resolution: | Type | Description | | --- | --- | | `string` | the device language | **Examples** Default Example 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" } ``` To subscribe to notifications when the value changes, pass a function as the only parameter: ``` function language(subscriber: (lang: string) => void): Promise ``` Parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `subscriber` | `Function` | Yes | A callback that gets invoked when the value for language changes | Promise resolution: | Type | Summary | | --- | --- | | `listenerId` | The id of the listener that can be used with Localization.clear(listenerId) to unsubscribe | Callback parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `lang` | `string` | Yes | the device language | **Examples** Default Example JavaScript: ``` import { Localization } from '@firebolt-js/sdk' Localization.language(lang => { // property value was changed console.log(lang) }).then(listenerId => { // you can clear this listener w/ Localization.clear(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": { "listening": "true" } } ``` ``` { "jsonrpc": "2.0", "id": 1, "result": "en" } ``` --- ### latlon Get the approximate latitude and longitude coordinates of the device location ``` function latlon(): Promise<[number, number]> ``` Promise resolution: | Type | Description | | --- | --- | | `[number, number]` | lat/long tuple | **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 Listen for events from this module. To listen to a specific event pass the event name as the first parameter: ``` Localization.listen(event: string, (data: any) => void): Promise ``` Parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `event` | `string` | Yes | The event to listen for, see [Events](/docs/081-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/081-core-localization#events). | To listen to all events from this module pass only a callback, without specifying an event name: ``` Localization.listen((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/081-core-localization#events). | Callback parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `event` | `string` | Yes | The event that has occured listen for, see [Events](/docs/081-core-localization#events). | | `data` | `any` | Yes | The event data, which depends on which event is firing, see [Events](/docs/081-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 ``` function locale(): Promise ``` Promise resolution: | Type | Description | | --- | --- | | `string` | the device locale | **Examples** Default Example 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" } ``` --- ### locality Get the locality/city the device is located in ``` function locality(): Promise ``` Promise resolution: | Type | Description | | --- | --- | | `string` | the device city | **Examples** Default Example 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" } ``` --- ### once Listen for only one occurance of an event from this module. The callback will be cleared after one event. To listen to a specific event pass the event name as the first parameter: ``` Localization.once(event: string, (data: any) => void): Promise ``` Parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `event` | `string` | Yes | The event to listen for, see [Events](/docs/081-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/081-core-localization#events). | To listen to all events from this module pass only a callback, without specifying an event name: ``` Localization.once((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/081-core-localization#events). | Callback parameters: | Param | Type | Required | Summary | | --- | --- | --- | --- | | `event` | `string` | Yes | The event that has occured listen for, see [Events](/docs/081-core-localization#events). | | `data` | `any` | Yes | The event data, which depends on which event is firing, see [Events](/docs/081-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 ``` function postalCode(): Promise ``` Promise resolution: | Type | Description | | --- | --- | | `string` | the device postal code | **Examples** Default Example 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" } ``` --- ## Events ### Additional events The following events are documented as part of a related set of method APIs. For more information, follow the links under the "Documentation" column. | JavaScript | RPC | Payload | Documentation | | --- | --- | --- | --- | | languageChanged | onLanguageChanged | string | [language](/docs/081-core-localization#language) | ## Schemas ### LatLon ``` type LatLon = [number, number] ``` ---