---
# System prepended metadata

title: Integration with i18n
tags: [brew-js-react]

---

---
tags: brew-js-react
---

# Integration with i18n

It is common to have (usually) the first path segment to specifiy the language of content being rendered.

The i18n module is readily working with the router:

```typescript
import brew from "brew-js-react";
import i18n from "brew-js/extensions/i18n";
import router from "brew-js/extensions/router";

brew.with(router)(app => {
    app.useRouter({
        routes: [
            '/{language:[a-zA-z-]+}/{view}/*',
            '/*'
        ],
        baseUrl: '/' 
    });
    app.useI18n({
        languages: ['en', 'de'],
        routeParam: 'language' 
    });
});
```

In the above example, the i18n module will monitor the `langauge` route parameter (the first segment, accessible through `app.route.language`), and either set current language (`app.language`) to the specified one, or redirects the SPA to a path starting with the allowed default language.
