> For the complete documentation index, see [llms.txt](https://blueeast.gitbook.io/bluerain-plugin-intl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blueeast.gitbook.io/bluerain-plugin-intl/master.md).

# bluerain Internationalisation plugin

Adds internationalization through [react-intl-redux](https://github.com/ratson/react-intl-redux) . <https://blueeast.gitbook.io/bluerain-plugin-intl>

| 🌏 Web | 🖥 Electron | 📱 React Native |
| ------ | ----------- | --------------- |
| ✔️     | ✔️          | TBD             |

### Screenshots

NA

## Components

This plugin registers following components in the Component registry, so they can be reused later by other apps and plugins:

* FormattedMessage[Web](https://github.com/yahoo/react-intl/wiki/Components#formattedmessage)
* FormattedNumber[ Web](https://github.com/yahoo/react-intl/wiki/Components#formattednumber)
* FormattedPlural [Web](https://github.com/yahoo/react-intl/wiki/Components#formattedplural)
* FormattedDate [Web](https://github.com/yahoo/react-intl/wiki/Components#formatteddate)
* FormattedTime[Web](https://github.com/yahoo/react-intl/wiki/Components#formattedtime)
* FormattedRelative[Web](https://github.com/yahoo/react-intl/wiki/Components#formattedrelative)

#### IntlConsumer

This Component is used to provide Intl functionality as a prop

```jsx
<BR.Components.IntlConsumer>
  {({ children, intl }) => {

  return props.intl
  }}
</BR.Components.IntlConsumer>
```

## Hooks

### bluerain.intl.messages

This hook gives the ability to add custom intl messages.

**Parameters:**

| Name     | Type   | Description     |
| -------- | ------ | --------------- |
| messages | Object | The messages db |

**Returns:**

| Name     | Type   | Description     |
| -------- | ------ | --------------- |
| messages | Object | The messages db |

**Example:**

This example registers custom english and urdu messages to the system:

```javascript
BR.Filters.add('bluerain.intl.messages', function eng(messages) {
    const en = require('./lang/en.ts');
    const ur = require('./lang/ur.ts');

    messages.en =  Object.assign(messages.en ? messages.en : {}, en);
    messages.ur = Object.assign(messages.ur ? messages.ur : {}, ur);

    return messages;
});
```

## API

### IntlPluginConfigs

This is the default configuration set that is used at boot time.

#### **Properties**

* `locale` [**Array**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \[default: "en"] Tries to detect automatically, falls back to 'en'.
* `localeData` [**Array**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) An array of localData files.

### InternationalizationPlugin

#### **Extends Plugin**

react-intl plugin to add internationalization to BlueRain Apps

#### **Plugin Properties**

* `pluginName` [**string**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) "InternationalizationPlugin"
* `slug` [**string**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) "intl"

#### setLocale

Change app's locale

**setLocale Parameters**

* `locale` [**string**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) The locale id
* `ctx`  The BlueRain Context
* `localeData`[**Array**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
* `selectable`[**object**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)

  **withIntl**

Higher Order component in inject `intl` prop in Component

#### **Parameters**

* `Component` **Component**

Returns **Component**

#### injectIntl

`react-intl`'s higher order component

#### **injectIntl Parameters**

* `Component` **Component**

Returns **Component**


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://blueeast.gitbook.io/bluerain-plugin-intl/master.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
