# LocaleModule

The `LocaleModule` class encapsulates access to the locale identifier of the device.

## Example

```
//==============================================================================
// The following example demonstrates how to detect the device language and
// log a greeting in that language.
//==============================================================================

// Load in the required modules
const Diagnostics = require('Diagnostics');
const Locale = require('Locale');

// Store the unedited locale string (made up of the language_territory)
const languageAndTerritory = Locale.fromDevice;

// Log the locale string to the Console
Diagnostics.log('My location and territory are ' + languageAndTerritory);

// Create an array by splitting the locale string, this array will have two
// values, the language [0] and the territory [1]
const localeAsArray = languageAndTerritory.split('_');

// Store the first element in the array (the language)
const language = localeAsArray[0];

// Use a switch statement to say hello in the Console in the correct language
switch (language) {
  // English
  case 'en':
    Diagnostics.log('Hello');
    break;
  // Spanish
  case 'es':
    Diagnostics.log('Hola');
    break;
  // French
  case 'fr':
    Diagnostics.log('Bonjour');
    break;
  // Other
  default:
    Diagnostics.log('Device language is neither English, Spanish nor French');
    break;
}
```

## Properties

| Property     | Description                                                                                                                                                                                                  |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `fromDevice` | <p><code>(get) fromDevice: string (set) (Not Available)</code></p><p>Provides the ISO 639-1 language + ISO 3166-1 region compliant locale identifier, e.g. <code>en\_US</code> or <code>zh\_HK</code>.</p>   |
| `language`   | <p><code>(get) language: StringSignal (set) (Not Available)</code></p><p>Provides the ISO 639-1 compliant language identifier, e.g. <code>en</code> or <code>zh</code>.</p>                                  |
| `locale`     | <p><code>(get) locale: StringSignal (set) (Not Available)</code></p><p>Provides the ISO 639-1 language + ISO 3166-1 region compliant locale identifier, e.g. <code>en\_US</code> or <code>zh\_HK</code>.</p> |
| `region`     | <p><code>(get) region: StringSignal (set) (Not Available)</code></p><p>Provides the ISO 3166-1 region identifier, e.g. <code>US</code>, or <code>HK</code>.</p>                                              |

## Methods

This module exposes no methods.

## Classes

This module exposes no classes.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sparkar-community.gitbook.io/docs/localemodule.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
