# frontend-localization

`@orchard/frontend-localization` provided by frontend-workstation. Requiring/importing this module will return a scoped instance for the caller. Meaning the instance given already "knows" for which module it belongs.

This allows us to call the e.g. the `formatMessage` function without telling from which translation registry it should use.

```jsx
import { formatMessage } from '@orchard/frontend-localization';

const MyComponent = () => <div>{formatMessage('somemessage')}</div>;
```

## getCurrentLocale

```ts
getCurrentLocale() : string
```

Returns the ISO code for the current user locale.

## formatMessage

```ts
formatMessage( term: string, args?: { [key:string]: any } ): string
```

Locates the given term and returns the matched translated text.

## registerTranslations

```ts
registerTranslations( { [code: string]: { [term: string]: string } } ): void
```

Internal function called to automatically register module translated languages. Calling this manually would register translations only for the module.

## setCurrentLocale

```ts
setCurrentLocale( code: string ): void
```

Sets the current locale. **Note** that this will affect the whole application and not just the module. Called internally by `frontend-workstation` on initial load.
