Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Andrii Bodnar <andrii.bodnar@crowdin.com>
  • Loading branch information
timofei-iatsenko and andrii-bodnar committed Mar 17, 2023
1 parent 7e8259d commit 8658981
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions website/docs/ref/loader.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Webpack Loader

Webpack loader which compiles catalogs on the fly. In summary, `lingui compile` command isn't required when using this loader
The Webpack loader compiles catalogs on the fly. In summary, the `lingui compile` command isn't needed when using this loader.

## Installation

Expand All @@ -14,7 +14,8 @@ npm install --save-dev @lingui/loader

Simply prepend `@lingui/loader!` in front of path to message catalog you want to import. Here's an example of dynamic import:

Extension is mandatory.
The extension is mandatory.

```ts
export async function dynamicActivate(locale: string) {
const { messages } = await import(`@lingui/loader!./locales/${locale}/messages.po`)
Expand All @@ -24,10 +25,10 @@ export async function dynamicActivate(locale: string) {
```

:::note
Catalogs with `.json` extension treated differently by Webpack. They loaded as ES module with default export, so your import should look like that:
Catalogs with the `.json` extension are treated differently by Webpack. They load as ES module with default export, so your import should look like this:

```ts
const { messages } = (await import(`@lingui/loader!./locales/${locale}/messages.po`)).default
const { messages } = (await import(`@lingui/loader!./locales/${locale}/messages.json`)).default
```
:::

Expand Down

0 comments on commit 8658981

Please sign in to comment.