Skip to content

Commit 473b70f

Browse files
docs: various chores (#2078)
1 parent d10fc32 commit 473b70f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+270
-287
lines changed

vercel.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
{ "source": "/tutorials/explicit-vs-generated-ids", "destination": "/guides/explicit-vs-generated-ids", "permanent": true},
1212
{ "source": "/tutorials/setup-vite", "destination": "/installation#vite", "permanent": true },
1313
{ "source": "/tutorials/setup-react", "destination": "/installation", "permanent": true },
14-
{ "source": "/tutorials/react-patterns", "destination": "/tutorials/react", "permanent": true }
14+
{ "source": "/tutorials/react-patterns", "destination": "/tutorials/react", "permanent": true },
15+
{ "source": "/misc/community", "destination": "/community", "permanent": true },
16+
{ "source": "/misc/examples", "destination": "/examples", "permanent": true }
1517
]
1618
}

website/.remarkrc.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export default {
3939
],
4040

4141
// Rules enabled by default by presents above that we don't want
42-
["remark-lint-code-block-style", false],
4342
["remark-lint-file-extension", false],
4443
["remark-lint-heading-style", false],
4544
["remark-lint-list-item-indent", false],
File renamed without changes.
File renamed without changes.

website/docs/guides/custom-formatter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to write a custom localization message formatter for your
55

66
# Custom Formatter
77

8-
If your project requires a message catalog format that Lingui doesn't [natively support](/docs/ref/catalog-formats.md), you can create a custom formatter to handle it. A custom formatter allows you to define how extracted strings are formatted into a custom catalog format, providing flexibility for specialized workflows and integration with unique file structures.
8+
If your project requires a message catalog format that Lingui doesn't [natively support](/ref/catalog-formats), you can create a custom formatter to handle it. A custom formatter allows you to define how extracted strings are formatted into a custom catalog format, providing flexibility for specialized workflows and integration with unique file structures.
99

1010
## Overview
1111

website/docs/guides/dynamic-loading-catalogs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Learn how to set up dynamic loading of message catalogs in Lingui t
77

88
Internationalization in modern applications requires careful handling of localized messages to avoid bloating the initial bundle size. By default, Lingui makes it easy to load all strings for a single active locale. For even greater efficiency, developers can selectively load only the messages needed on demand using [`i18n.load`](/ref/core#i18n.load), ensuring minimal resource usage.
99

10-
The [`I18nProvider`](/docs/ref/react.md#i18nprovider) component doesn't make assumptions about your app's structure, giving you the freedom to load only the necessary messages for the currently selected language.
10+
The [`I18nProvider`](/ref/react#i18nprovider) component doesn't make assumptions about your app's structure, giving you the freedom to load only the necessary messages for the currently selected language.
1111

1212
This guide shows how to set up dynamic loading of message catalogs, ensuring only the needed catalogs are loaded, which reduces bundle size and improves performance.
1313

website/docs/guides/explicit-vs-generated-ids.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function render() {
148148
}
149149
```
150150

151-
In the example code above, the content of [`Trans`](/docs/ref/macro.mdx#trans) is transformed into a message in MessageFormat syntax. By default, this message is used for generating the ID. Considering the example above, the catalog would contain these entries:
151+
In the example code above, the content of [`Trans`](/ref/macro#trans) is transformed into a message in MessageFormat syntax. By default, this message is used for generating the ID. Considering the example above, the catalog would contain these entries:
152152

153153
```js
154154
const catalog = [
@@ -202,7 +202,7 @@ The messages with IDs `msg.header` and `msg.hello` will be extracted with their
202202

203203
### With Core Macro
204204

205-
To use custom IDs in non-JSX macros, call the [`msg`](/docs/ref/macro.mdx#definemessage) function with a message descriptor object, passing the ID using the `id` property:
205+
To use custom IDs in non-JSX macros, call the [`msg`](/ref/macro#definemessage) function with a message descriptor object, passing the ID using the `id` property:
206206

207207
```jsx
208208
import { msg } from "@lingui/core/macro";
@@ -212,7 +212,7 @@ msg({ id: "msg.greeting", message: `Hello World` });
212212

213213
Message `msg.greeting` will be extracted with default value `Hello World`.
214214

215-
For all other js macros ([`plural`](/docs/ref/macro.mdx#plural), [`select`](/docs/ref/macro.mdx#select), [`selectOrdinal`](/docs/ref/macro.mdx#selectordinal), use them inside [`msg`](/docs/ref/macro.mdx#definemessage) macro to pass ID (in this case, `'msg.caption'`).
215+
For all other js macros ([`plural`](/ref/macro#plural), [`select`](/ref/macro#select), [`selectOrdinal`](/ref/macro#selectordinal), use them inside [`msg`](/ref/macro#definemessage) macro to pass ID (in this case, `'msg.caption'`).
216216

217217
```jsx
218218
import { msg, plural } from "@lingui/core/macro";
@@ -228,5 +228,5 @@ msg({
228228

229229
## See Also
230230

231-
- [Message Extraction](/docs/guides/message-extraction.md)
232-
- [Macros Reference](/docs/ref/macro.mdx)
231+
- [Message Extraction](/guides/message-extraction)
232+
- [Macros Reference](/ref/macro)

website/docs/guides/lazy-translations.md

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ description: Lazy translations allow you to defer translation of a message until
55

66
# Lazy Translations
77

8-
Lazy translation allows you to defer translation of a message until it's rendered, giving you flexibility in how and where you define messages in your code. With lazy translation, you can tag a string with the [`msg`](/docs/ref/macro.mdx#definemessage) macro to create a _message descriptor_ that can be saved, passed around as a variable, and rendered later.
8+
Lazy translation allows you to defer translation of a message until it's rendered, giving you flexibility in how and where you define messages in your code. With lazy translation, you can tag a string with the [`msg`](/ref/macro#definemessage) macro to create a _message descriptor_ that can be saved, passed around as a variable, and rendered later.
99

1010
## Usage Example
1111

12-
To render the message descriptor as a string-only translation, pass it to the [`i18n._()`](/docs/ref/core.md#i18n._) method:
12+
To render the message descriptor as a string-only translation, pass it to the [`i18n._()`](/ref/core#i18n._) method:
1313

1414
```jsx
1515
import { msg } from "@lingui/core/macro";
@@ -24,7 +24,7 @@ export function getTranslatedColorNames() {
2424

2525
## Usage in React
2626

27-
To render the message descriptor in a React component, pass its `id` to the [`Trans`](/docs/ref/react.md#trans) component as a value of the `id` prop:
27+
To render the message descriptor in a React component, pass its `id` to the [`Trans`](/ref/react#trans) component as a value of the `id` prop:
2828

2929
```jsx
3030
import { msg } from "@lingui/core/macro";
@@ -53,7 +53,7 @@ Please note that we import the `<Trans>` component from `@lingui/react` to use t
5353

5454
Sometimes you need to choose between different messages to display depending on the value of a variable. For example, imagine you have a numeric "status" code that comes from an API, and you need to display a message that represents the current status.
5555

56-
An easy way to do this is to create an object that maps the possible values of "status" to message descriptors (tagged with the [`msg`](/docs/ref/macro.mdx#definemessage) macro) and render them as needed with deferred translation:
56+
An easy way to do this is to create an object that maps the possible values of "status" to message descriptors (tagged with the [`msg`](/ref/macro#definemessage) macro) and render them as needed with deferred translation:
5757

5858
```jsx
5959
import { msg } from "@lingui/core/macro";
@@ -76,18 +76,14 @@ export default function StatusDisplay({ statusCode }) {
7676

7777
In the following contrived example, we document how a welcome message will or will not be updated when locale changes. The documented behavior may not be intuitive at first, but it is expected, because of the way the `useMemo` dependencies work.
7878

79-
To avoid bugs with stale translations, use the `_` function returned from the [`useLingui`](/docs/ref/react.md#uselingui) hook: it is safe to use with memoization because its reference changes whenever the Lingui context updates.
80-
81-
:::tip
82-
You can also use the `t` function from the [`useLingui`](/docs/ref/macro.mdx#uselingui) macro hook, which behaves the same way as `_` from the runtime [`useLingui`](/docs/ref/react.md#uselingui) counterpart.
83-
:::
79+
To avoid bugs with stale translations, use the `t` function returned from the [`useLingui`](/ref/macro#uselingui) macro: it is safe to use with memoization because its reference changes whenever the Lingui context updates.
8480

8581
Keep in mind that `useMemo` is primarily a performance optimization tool in React. Because of this, there might be no need to memoize your translations. Additionally, this issue is not present when using the `Trans` component, which we recommend using whenever possible.
8682

8783
```jsx
88-
import { msg } from "@lingui/core/macro";
8984
import { i18n } from "@lingui/core";
90-
import { useLingui } from "@lingui/react";
85+
import { msg } from "@lingui/core/macro";
86+
import { useLingui } from "@lingui/react/macro";
9187

9288
const welcomeMessage = msg`Welcome!`;
9389

@@ -111,24 +107,13 @@ export function Welcome() {
111107
return <div>{buggyWelcome}</div>;
112108
}
113109

114-
// ✅ Good! `useMemo` has i18n context in the dependency
110+
// ✅ Good! `useMemo` consumes the `t` function from the `useLingui` macro
115111
export function Welcome() {
116-
const linguiCtx = useLingui();
117-
118-
const welcome = useMemo(() => {
119-
return linguiCtx.i18n._(welcomeMessage);
120-
}, [linguiCtx]);
121-
122-
return <div>{welcome}</div>;
123-
}
124-
125-
// 🤩 Better! `useMemo` consumes the `_` function from the Lingui context
126-
export function Welcome() {
127-
const { _ } = useLingui();
112+
const { t } = useLingui();
128113

129114
const welcome = useMemo(() => {
130-
return _(welcomeMessage);
131-
}, [_]);
115+
return t(welcomeMessage);
116+
}, [t]);
132117

133118
return <div>{welcome}</div>;
134119
}

website/docs/guides/message-extraction.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Message extraction is a key part of the internationalization process. It involve
99

1010
In practice, developers define messages directly in the source code, and the extraction tool automatically collects these messages and stores them in a message catalog for translation.
1111

12-
Read more about the [`lingui extract`](/docs/ref/cli.md) command.
12+
Read more about the [`lingui extract`](/ref/cli#extract) command.
1313

1414
## Supported Patterns
1515

@@ -19,7 +19,7 @@ The extractor operates at a static level, meaning that it analyzes the source co
1919

2020
> Macros are JavaScript transformers that run at build time. The value returned by a macro is inlined into the bundle instead of the original function call.
2121
22-
The Lingui Macro provides powerful macros to transform JavaScript objects and JSX elements into [ICU MessageFormat](/docs/guides/message-format.md) messages at compile time.
22+
The Lingui Macro provides powerful macros to transform JavaScript objects and JSX elements into [ICU MessageFormat](/guides/message-format) messages at compile time.
2323

2424
Extractor supports all macro usage, such as the following examples:
2525

@@ -39,7 +39,7 @@ const jsx = <Trans>Hi, my name is {name}</Trans>;
3939

4040
The extractor matches the `t` and `Trans` macro calls and extracts the messages from them.
4141

42-
For more usage examples, see to the [Macros](/docs/ref/macro.mdx) reference.
42+
For more usage examples, see to the [Macros](/ref/macro) reference.
4343

4444
### Non-Macros Usage
4545

@@ -108,7 +108,7 @@ The extractor can locate source files in two ways: by specifying a glob pattern
108108

109109
By default, `lingui extract` uses a glob pattern to search for source files containing messages.
110110

111-
The pattern is defined in the [`catalogs`](/docs//ref/conf.md#catalogs) property of the Lingui configuration file in your project's root directory.
111+
The pattern is defined in the [`catalogs`](/ref/conf#catalogs) property of the Lingui configuration file in your project's root directory.
112112

113113
![Scheme of discovering by glob pattern](/img/docs/extractor-glob-scheme.jpg#gh-light-mode-only)
114114
![Scheme of discovering by glob pattern](/img/docs/extractor-glob-scheme-dark.jpg#gh-dark-mode-only)
@@ -208,10 +208,10 @@ The extractor supports TypeScript, Flow, and JavaScript (Stage 3) out of the box
208208

209209
If you are using some experimental features (Stage 0 - Stage 2) or frameworks with custom syntax such as Vue.js or Svelte, you may want to implement your own custom extractor.
210210

211-
Visit [Custom Extractor](/docs/guides/custom-extractor.md) to learn how to create a custom extractor.
211+
Visit [Custom Extractor](/guides/custom-extractor) to learn how to create a custom extractor.
212212

213213
## See Also
214214

215-
- [Lingui CLI Reference](/docs/ref/cli.md)
216-
- [Macros Reference](/docs/ref/macro.mdx)
217-
- [Catalog Formats](/docs/ref/catalog-formats.md)
215+
- [Lingui CLI Reference](/ref/cli)
216+
- [Macros Reference](/ref/macro)
217+
- [Catalog Formats](/ref/catalog-formats)

website/docs/guides/message-format.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ Example: `Attachment {name} saved`
5757

5858
## See Also
5959

60-
- [Pluralization](/docs/guides/plurals.md)
60+
- [Pluralization](/guides/plurals)
6161
- [ICU Playground](https://format-message.github.io/icu-message-format-for-translators/editor.html)

0 commit comments

Comments
 (0)