---
tags: brew-js
---
# useI18n
Allows detection of browser language preferences and provide ways to define app's current language explicitly or through router.
```typescript
import brew from "brew-js/core";
import I18n from "brew/extensions/i18n";
brew.with(I18n)(app => {
app.useI18n(options);
});
```
## Options
### `languages`
A list of available languages.
### `detectLanguage`
<span style="background: lightblue;padding:.25em .75em;border-radius:1em;font-weight:bold">v0.4.8</span>
```typescript!
detectLanguage?: boolean;
```
Whether to detect language from browser preferences.
:::info
For best interoperabilitiy, it is recommended to use standard BCP language code in the `languages` list.
:::
### `defaultLanguage`
```typescript!
defaultLanguage?: string;
```
### `routeParam`
When defined, the current language will be reflected on the specified route parameters. Updating either `app.language` or `app.route[routeParam]` will cause the other to change.
If the route parameter resolves to a language not defined in the `languages` list, the defafult language will be set instead and will cause the app to redirect to the corresponding path.
:::warning
Note that the route parameter will subject to constraints given by the allowed routes. If constraint is needed on route parameter, be sure it matches the available languages.
:::
## Listening for language change
```typescript
app.watch('language', (newLanguage) => {
// ...
});
```