Skip to content

Commit d36c323

Browse files
docs: various minor updates (#2177)
* docs: date and time MessageFormat syntax * docs: add comment to examples * chore: minor refactoring of blog social images
1 parent f668c5c commit d36c323

File tree

7 files changed

+28
-6
lines changed

7 files changed

+28
-6
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ import { Trans } from "@lingui/react/macro"
5858

5959
function App() {
6060
return (
61-
<Trans id="msg.docs" /* id is optional */>
61+
<Trans
62+
id="msg.docs" // Optional message id
63+
comment="Docs link on the website" // Comment for translators, optional
64+
>
6265
Read the <a href="https://lingui.dev">documentation</a>
6366
for more info.
6467
</Trans>

website/blog/2023-04-26-announcing-lingui-4.0/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
title: Announcing Lingui 4.0
33
authors: andrii-bodnar
44
tags: [release]
5-
image: ./img/social-card.png
5+
image: ./social-card.png
66
---
77

88
Today we are happy to finally announce Lingui 4.0! 🥳️
99

1010
---
1111

12-
![social-card image](./img/social-card.png)
12+
![social-card image](./social-card.png)
1313

1414
## What is Lingui exactly?
1515

website/blog/2023-12-12-4k-stars/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
title: Lingui hits 4k Stars on GitHub ⭐
33
authors: andrii-bodnar
44
tags: [news, community]
5-
image: ./img/social-card.png
5+
image: ./social-card.png
66
---
77

8-
![social-card image](./img/social-card.png)
8+
![social-card image](./social-card.png)
99

1010
We're thrilled to announce that the [Lingui repository](https://github.com/lingui/js-lingui) has reached an important milestone - **4,000** stars! This achievement is a testament to the growing popularity of Lingui as a powerful and flexible internationalization solution for global products.
1111

website/docs/ref/core.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ The core method for translating and formatting messages.
153153
- `messageId`: a unique message ID which identifies message in catalog.
154154
- `values`: an object containing variables used in translated message.
155155
- `options.message`: the default translation (optional). This is mostly used when application doesn't use message IDs in natural language (e.g.: `msg.id` or `Component.title`).
156+
- `options.formats`: custom format definitions for dates and times (optional). An object where keys are format names and values are either `Intl.DateTimeFormatOptions` or `Intl.NumberFormatOptions`.
156157

157158
```ts
158159
import { i18n } from "@lingui/core";
@@ -165,6 +166,21 @@ i18n._("My name is {name}", { name: "Tom" });
165166

166167
// Message with custom messageId
167168
i18n._("msg.id", { name: "Tom" }, { message: "My name is {name}" });
169+
170+
const date = new Date("2014-12-06");
171+
const time = new Date("2014-12-06T17:40:00Z");
172+
173+
// Short date format
174+
i18n._("It starts on {someDate, date, short}", { someDate: date });
175+
176+
// Short time format
177+
i18n._("It starts on {someTime, time, short}", { someTime: time });
178+
179+
// Date skeleton format
180+
i18n._("It starts on {someDate, date, ::GrMMMdd}", { someDate: date });
181+
182+
// Custom date format
183+
i18n._("It starts on {someDate, date, myStyle}", { someDate: date }, { formats: { myStyle: { day: "numeric" } } });
168184
```
169185

170186
### `i18n._(messageDescriptor)`

website/src/components/Code.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import { Trans } from "@lingui/react/macro"
1111
1212
function App() {
1313
return (
14-
<Trans id="msg.docs">
14+
<Trans
15+
id="msg.docs" // Optional message id
16+
comment="Docs link on the website" // Comment for translators, optional
17+
>
1518
Read the <a href="https://lingui.dev">documentation</a>
1619
for more info.
1720
</Trans>

0 commit comments

Comments
 (0)