use-intl 2.21.0 → 2.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
Internationalization is an essential part of the user experience. use-intl gives you everything you need to get language subtleties right and has always got your back whenever you need to fine-tune a translation.
|
|
10
10
|
|
|
11
|
-
- 🌟 **ICU message syntax**: Localize your messages with interpolation,
|
|
11
|
+
- 🌟 **ICU message syntax**: Localize your messages with interpolation, cardinal & ordinal plurals, enum-based label selection and rich text.
|
|
12
12
|
- 📅 **Dates, times & numbers**: Apply appropriate formatting without worrying about server/client differences like time zones.
|
|
13
13
|
- ✅ **Type-safe**: Speed up development with autocompletion for message keys and catch typos early with compile-time checks.
|
|
14
14
|
- 💡 **Hooks-only API**: Learn a single API that can be used across your code base to turn translations into plain strings or rich text.
|
|
@@ -19,36 +19,33 @@ Internationalization is an essential part of the user experience. use-intl gives
|
|
|
19
19
|
This library is based on the premise that messages can be grouped by namespaces (typically a component name).
|
|
20
20
|
|
|
21
21
|
```jsx
|
|
22
|
-
//
|
|
23
|
-
import {useTranslations
|
|
22
|
+
// UserProfile.tsx
|
|
23
|
+
import {useTranslations} from 'next-intl';
|
|
24
24
|
|
|
25
|
-
function
|
|
26
|
-
const t = useTranslations('
|
|
27
|
-
const format = useFormatter();
|
|
25
|
+
export default function UserProfile({user}) {
|
|
26
|
+
const t = useTranslations('UserProfile');
|
|
28
27
|
|
|
29
28
|
return (
|
|
30
29
|
<section>
|
|
31
|
-
<
|
|
32
|
-
<p>{t('
|
|
33
|
-
<p>{t('
|
|
34
|
-
<Image alt={t('portrait', {username: user.name})} src={user.portrait} />
|
|
30
|
+
<h1>{t('title', {firstName: user.firstName})}</h1>
|
|
31
|
+
<p>{t('membership', {memberSince: user.memberSince})}</p>
|
|
32
|
+
<p>{t('followers', {count: user.numFollowers})}</p>
|
|
35
33
|
</section>
|
|
36
34
|
);
|
|
37
35
|
}
|
|
38
36
|
```
|
|
39
37
|
|
|
40
|
-
```
|
|
38
|
+
```json
|
|
41
39
|
// en.json
|
|
42
40
|
{
|
|
43
|
-
"
|
|
44
|
-
"title": "
|
|
41
|
+
"UserProfile": {
|
|
42
|
+
"title": "{username}'s profile",
|
|
43
|
+
"membership": "Member since {memberSince, date, short}",
|
|
45
44
|
"followers": "{count, plural, ↵
|
|
46
45
|
=0 {No followers yet} ↵
|
|
47
46
|
=1 {One follower} ↵
|
|
48
47
|
other {# followers} ↵
|
|
49
|
-
}"
|
|
50
|
-
"lastSeen": "Last seen {time}",
|
|
51
|
-
"portrait": "Portrait of {username}"
|
|
48
|
+
}"
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
51
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "use-intl",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"description": "Minimal, but complete solution for managing internationalization in React apps.",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"engines": {
|
|
73
73
|
"node": ">=10"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "b1688dea14c9367972568239160e7f2403bfb4ab"
|
|
76
76
|
}
|