Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
timofei-iatsenko committed Oct 4, 2024
1 parent 3ba0769 commit 918c5b3
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions website/docs/ref/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,32 @@ Formatting of messages as strings (e.g: `"My name is {name}"`) works in developm
The same example would in real application look like this:

```ts
import { i18n } from "@lingui/core"
import { i18n } from "@lingui/core";

// File generated by `lingui compile`
import { messages: messagesEn } from "./locale/en/messages.js"
import { messages as messagesEn } from "./locale/en/messages.js";

i18n.load('en', messagesEn)
i18n.load("en", messagesEn);
```

:::

### `i18n.setMessagesCompiler(compiler)` {#i18n.setMessagesCompiler}

Registers a `MessageCompiler` to enable the use of uncompiled catalogs at runtime.

In production builds, the `MessageCompiler` is typically excluded to reduce bundle size.

By default, message catalogs should be precompiled during the build process. However, if you need to compile catalogs at runtime, you can use this method to set a message compiler.

Example usage:

```ts
import { compileMessage } from "@lingui/message-utils/compileMessage";

i18n.setMessagesCompiler(compileMessage);
```

### `i18n.activate(locale[, locales])` {#i18n.activate}

Activate a locale and locales. From now on, calling `i18n._` will return messages in given locale.
Expand Down

0 comments on commit 918c5b3

Please sign in to comment.