@pcdevil/eleventy-plugin-intl-utils 2.0.0 → 2.0.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 +66 -27
- package/package.json +11 -8
package/README.md
CHANGED
|
@@ -2,19 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
A set of internationalization utils for [Eleventy](https://www.11ty.dev/).
|
|
4
4
|
|
|
5
|
-
💙 This project is made by humans for humans - using it with LLM models is
|
|
5
|
+
💙 This project is made by humans for humans - using it with LLM models is
|
|
6
|
+
strongly discouraged: the [AGENTS.md](AGENTS.md) and [CLAUDE.md](CLAUDE.md)
|
|
7
|
+
files only exist to instruct such tools to halt any action.
|
|
6
8
|
|
|
7
9
|
## Motivation
|
|
8
10
|
|
|
9
|
-
It's super fast to create a static website with **Eleventy** and with the help
|
|
11
|
+
It's super fast to create a static website with **Eleventy** and with the help
|
|
12
|
+
of [`eleventy-plugin-i18n`](https://www.npmjs.com/package/eleventy-plugin-i18n)
|
|
13
|
+
localization can be done with ease too.
|
|
10
14
|
|
|
11
|
-
However it only gives solution for static data and dynamic data still needs
|
|
15
|
+
However it only gives solution for static data and dynamic data still needs
|
|
16
|
+
treatment during layout rendering. This plugin aims to help with a set of
|
|
17
|
+
[filters](https://www.11ty.dev/docs/filters/) and
|
|
18
|
+
[shortcodes](https://www.11ty.dev/docs/shortcodes/).
|
|
12
19
|
|
|
13
|
-
The implementations of the filters are mostly wrappers around the
|
|
20
|
+
The implementations of the filters are mostly wrappers around the
|
|
21
|
+
[ECMAScript Internationalization API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl)
|
|
22
|
+
with a little _bit of sugar_.
|
|
14
23
|
|
|
15
24
|
## Usage
|
|
16
25
|
|
|
17
|
-
This guide corresponds to
|
|
26
|
+
This guide corresponds to
|
|
27
|
+
[Eleventy documentation](https://www.11ty.dev/docs/plugins/#add-the-plugin-to-eleventy-in-your-config-file):
|
|
18
28
|
|
|
19
29
|
1. Install the package
|
|
20
30
|
```bash
|
|
@@ -37,23 +47,30 @@ This guide corresponds to [Eleventy documentation](https://www.11ty.dev/docs/plu
|
|
|
37
47
|
|
|
38
48
|
## Configuration object
|
|
39
49
|
|
|
40
|
-
A general configuration object can be passed optionally via Eleventy config when
|
|
50
|
+
A general configuration object can be passed optionally via Eleventy config when
|
|
51
|
+
the plugin is initiated. This sections lists the available configuration
|
|
52
|
+
properties.
|
|
41
53
|
|
|
42
54
|
### `locale`
|
|
43
55
|
|
|
44
|
-
This property affects the output language of the filters. See
|
|
56
|
+
This property affects the output language of the filters. See
|
|
57
|
+
[`locales` argument section on Intl page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument)
|
|
58
|
+
for more info.
|
|
45
59
|
|
|
46
60
|
- **Type**: String
|
|
47
|
-
- **Default value**: `undefined` (**Node.js** will pick up the system's
|
|
61
|
+
- **Default value**: `undefined` (**Node.js** will pick up the system's
|
|
62
|
+
language)
|
|
48
63
|
- **Example values**: `"en-GB"`, `"hu"`
|
|
49
64
|
|
|
50
65
|
## Filters
|
|
51
66
|
|
|
52
67
|
### `country_name`
|
|
53
68
|
|
|
54
|
-
Transforms a country code into a country name. Useful to display author's
|
|
69
|
+
Transforms a country code into a country name. Useful to display author's
|
|
70
|
+
location.
|
|
55
71
|
|
|
56
|
-
- **Used Internationalization API**: `Intl.DisplayNames()` with _region_ type
|
|
72
|
+
- **Used Internationalization API**: `Intl.DisplayNames()` with _region_ type
|
|
73
|
+
([MDN article](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames))
|
|
57
74
|
|
|
58
75
|
#### LiquidJS Example
|
|
59
76
|
|
|
@@ -66,9 +83,11 @@ This renders "France" when the `intlUtilConfig.locale` is `en`.
|
|
|
66
83
|
|
|
67
84
|
### `language_name`
|
|
68
85
|
|
|
69
|
-
Transforms a language code to a renderable text. Useful for language selectors
|
|
86
|
+
Transforms a language code to a renderable text. Useful for language selectors
|
|
87
|
+
or when the current language is displayed.
|
|
70
88
|
|
|
71
|
-
- **Used Internationalization API**: `Intl.DisplayNames()` with _language_ type
|
|
89
|
+
- **Used Internationalization API**: `Intl.DisplayNames()` with _language_ type
|
|
90
|
+
([MDN article](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#using_type_language_with_languagedisplay))
|
|
72
91
|
|
|
73
92
|
#### LiquidJS Example
|
|
74
93
|
|
|
@@ -83,7 +102,9 @@ This renders "British English" when the `intlUtilConfig.locale` is `en`.
|
|
|
83
102
|
|
|
84
103
|
Transforms a date string to a short date time text. Useful for blog post dates.
|
|
85
104
|
|
|
86
|
-
- **Used Internationalization API**: `Intl.DateTimeFormat()` with _short_ date
|
|
105
|
+
- **Used Internationalization API**: `Intl.DateTimeFormat()` with _short_ date
|
|
106
|
+
and time style
|
|
107
|
+
([MDN article](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat))
|
|
87
108
|
|
|
88
109
|
#### LiquidJS Example
|
|
89
110
|
|
|
@@ -98,11 +119,15 @@ This renders "12/12/21, 5:36 PM" when the `intlUtilConfig.locale` is `en`.
|
|
|
98
119
|
|
|
99
120
|
### `year_interval`
|
|
100
121
|
|
|
101
|
-
Transforms two date strings to a year range. Useful when a larger time interval
|
|
122
|
+
Transforms two date strings to a year range. Useful when a larger time interval
|
|
123
|
+
is presented.
|
|
102
124
|
|
|
103
|
-
The input should be an array with two date string and the first one should
|
|
125
|
+
The input should be an array with two date string and the first one should
|
|
126
|
+
precede before the second one.
|
|
104
127
|
|
|
105
|
-
- **Used Internationalization API**:
|
|
128
|
+
- **Used Internationalization API**:
|
|
129
|
+
`Intl.DateTimeFormat.prototype.formatRange()` with _numeric_ year
|
|
130
|
+
([MDN article](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRange))
|
|
106
131
|
|
|
107
132
|
#### LiquidJS Example
|
|
108
133
|
|
|
@@ -112,11 +137,13 @@ The input should be an array with two date string and the first one should prece
|
|
|
112
137
|
{% year_interval startDate, endDate %}
|
|
113
138
|
```
|
|
114
139
|
|
|
115
|
-
This renders "2011 – 2020" (with en dash in the middle) when the
|
|
140
|
+
This renders "2011 – 2020" (with en dash in the middle) when the
|
|
141
|
+
`intlUtilConfig.locale` is `en`.
|
|
116
142
|
|
|
117
143
|
#### Fallback value
|
|
118
144
|
|
|
119
|
-
The second `endDate` argument can be omitted and it has the current date as
|
|
145
|
+
The second `endDate` argument can be omitted and it has the current date as
|
|
146
|
+
default value.
|
|
120
147
|
|
|
121
148
|
This behaviour helps when an open-ended / ongoing interval needs be displayed:
|
|
122
149
|
|
|
@@ -125,13 +152,17 @@ This behaviour helps when an open-ended / ongoing interval needs be displayed:
|
|
|
125
152
|
{% year_interval startDate %}
|
|
126
153
|
```
|
|
127
154
|
|
|
128
|
-
This renders "2011 – 2021" (with en dash in the middle) when the
|
|
155
|
+
This renders "2011 – 2021" (with en dash in the middle) when the
|
|
156
|
+
`intlUtilConfig.locale` is `en` and the current year is 2021.
|
|
129
157
|
|
|
130
158
|
### `year_open_interval`
|
|
131
159
|
|
|
132
|
-
Transforms a date string into an _open_ year range where the end date is absent.
|
|
160
|
+
Transforms a date string into an _open_ year range where the end date is absent.
|
|
161
|
+
Useful when a ongoing interval is presented.
|
|
133
162
|
|
|
134
|
-
- **Used Internationalization API**:
|
|
163
|
+
- **Used Internationalization API**:
|
|
164
|
+
`Intl.DateTimeFormat.prototype.formatRange()` with _numeric_ year
|
|
165
|
+
([MDN article](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatRange))
|
|
135
166
|
|
|
136
167
|
#### LiquidJS Example
|
|
137
168
|
|
|
@@ -140,18 +171,26 @@ Transforms a date string into an _open_ year range where the end date is absent.
|
|
|
140
171
|
{% year_interval startDate %}
|
|
141
172
|
```
|
|
142
173
|
|
|
143
|
-
This renders "2011 – " (with en dash in the middle) when the
|
|
174
|
+
This renders "2011 – " (with en dash in the middle) when the
|
|
175
|
+
`intlUtilConfig.locale` is `en`.
|
|
144
176
|
|
|
145
177
|
#### Difference from `year_interval`
|
|
146
178
|
|
|
147
|
-
While the [`year_interval`](#year_interval) shortcode always created a _closed_
|
|
179
|
+
While the [`year_interval`](#year_interval) shortcode always created a _closed_
|
|
180
|
+
year range (by applying the current year as default), the `year_open_interval`
|
|
181
|
+
only displays the start date.
|
|
148
182
|
|
|
149
183
|
## License and acknowledgments
|
|
150
184
|
|
|
151
|
-
The project is available under the **3-Clause BSD** license with an extension of
|
|
185
|
+
The project is available under the **3-Clause BSD** license with an extension of
|
|
186
|
+
prohibiting to use it with Gen-AI and LLMs tools, see the
|
|
187
|
+
[LICENSE.md](LICENSE.md) file.
|
|
152
188
|
|
|
153
|
-
"Human made content badge" badge created by **Andy Carolan**:
|
|
189
|
+
"Human made content badge" badge created by **Andy Carolan**:
|
|
190
|
+
<https://www.andycarolan.com/>
|
|
154
191
|
|
|
155
|
-
License based on **Aleksandar Prokopec**'s Non-AI Licenses:
|
|
192
|
+
License based on **Aleksandar Prokopec**'s Non-AI Licenses:
|
|
193
|
+
<https://github.com/non-ai-licenses/non-ai-licenses>
|
|
156
194
|
|
|
157
|
-
`AGENTS.md` is created by **Alice D.**:
|
|
195
|
+
`AGENTS.md` is created by **Alice D.**:
|
|
196
|
+
<https://codeberg.org/queer-computer-club/doorbot/src/branch/doorbot-pro-max-ultra-deluxe-se/AGENTS.md>
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pcdevil/eleventy-plugin-intl-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"description": "A set of internationalization utils for Eleventy.",
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": "^
|
|
11
|
-
"npm": "^
|
|
10
|
+
"node": "^26.12.1",
|
|
11
|
+
"npm": "^11.20.0"
|
|
12
12
|
},
|
|
13
|
-
"packageManager": "npm@
|
|
13
|
+
"packageManager": "npm@11.20.0",
|
|
14
14
|
"main": "./src/eleventy-plugin-intl-utils.mjs",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"files": [
|
|
@@ -49,10 +49,13 @@
|
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://codeberg.org/pcdevil/eleventy-plugin-intl-utils",
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@eslint/config-helpers": "~0.
|
|
52
|
+
"@eslint/config-helpers": "~0.7.0",
|
|
53
53
|
"@eslint/js": "^10.0.1",
|
|
54
|
-
"dprint": "~0.
|
|
55
|
-
"eslint": "^10.
|
|
56
|
-
"globals": "^17.
|
|
54
|
+
"dprint": "~0.64.1",
|
|
55
|
+
"eslint": "^10.13.0",
|
|
56
|
+
"globals": "^17.13.0"
|
|
57
|
+
},
|
|
58
|
+
"allowScripts": {
|
|
59
|
+
"dprint@*": true
|
|
57
60
|
}
|
|
58
61
|
}
|