@hazeljs/i18n 0.7.9 → 0.8.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 +18 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -152,22 +152,22 @@ I18nModule.forRootAsync({
|
|
|
152
152
|
translationsPath: config.get('TRANSLATIONS_PATH', './translations'),
|
|
153
153
|
}),
|
|
154
154
|
inject: [ConfigService],
|
|
155
|
-
})
|
|
155
|
+
});
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
## API Reference
|
|
159
159
|
|
|
160
160
|
### I18nModule.forRoot(options)
|
|
161
161
|
|
|
162
|
-
| Option | Type | Default
|
|
163
|
-
|
|
164
|
-
| `defaultLocale` | `string` | `'en'`
|
|
165
|
-
| `fallbackLocale` | `string` | same as `defaultLocale`
|
|
166
|
-
| `translationsPath` | `string` | `'./translations'`
|
|
167
|
-
| `detection` | `LocaleDetectionStrategy[]` | `['query','cookie','header']
|
|
168
|
-
| `queryParam` | `string` | `'lang'`
|
|
169
|
-
| `cookieName` | `string` | `'locale'`
|
|
170
|
-
| `isGlobal` | `boolean` | `true`
|
|
162
|
+
| Option | Type | Default | Description |
|
|
163
|
+
| ------------------ | --------------------------- | ----------------------------- | ----------------------------------------------- |
|
|
164
|
+
| `defaultLocale` | `string` | `'en'` | Locale used when none is detected. |
|
|
165
|
+
| `fallbackLocale` | `string` | same as `defaultLocale` | Locale used when a key is missing. |
|
|
166
|
+
| `translationsPath` | `string` | `'./translations'` | Path to the directory of `<locale>.json` files. |
|
|
167
|
+
| `detection` | `LocaleDetectionStrategy[]` | `['query','cookie','header']` | Ordered locale detection strategies. |
|
|
168
|
+
| `queryParam` | `string` | `'lang'` | Query-string parameter name. |
|
|
169
|
+
| `cookieName` | `string` | `'locale'` | Cookie name. |
|
|
170
|
+
| `isGlobal` | `boolean` | `true` | Register as a global module. |
|
|
171
171
|
|
|
172
172
|
### I18nService
|
|
173
173
|
|
|
@@ -177,16 +177,16 @@ I18nModule.forRootAsync({
|
|
|
177
177
|
- `getKeys(locale?)` - Return all flattened dot-notation keys for a locale
|
|
178
178
|
|
|
179
179
|
```typescript
|
|
180
|
-
i18n.t('errors.notFound')
|
|
180
|
+
i18n.t('errors.notFound');
|
|
181
181
|
// → "Resource not found."
|
|
182
182
|
|
|
183
|
-
i18n.t('welcome', { vars: { name: 'Bob' } })
|
|
183
|
+
i18n.t('welcome', { vars: { name: 'Bob' } });
|
|
184
184
|
// → "Welcome, Bob!"
|
|
185
185
|
|
|
186
|
-
i18n.t('items', { count: 3, vars: { count: '3' } })
|
|
186
|
+
i18n.t('items', { count: 3, vars: { count: '3' } });
|
|
187
187
|
// → "3 items"
|
|
188
188
|
|
|
189
|
-
i18n.t('welcome', { locale: 'fr', vars: { name: 'Bob' } })
|
|
189
|
+
i18n.t('welcome', { locale: 'fr', vars: { name: 'Bob' } });
|
|
190
190
|
// → "Bienvenue, Bob !"
|
|
191
191
|
```
|
|
192
192
|
|
|
@@ -198,16 +198,16 @@ i18n.t('welcome', { locale: 'fr', vars: { name: 'Bob' } })
|
|
|
198
198
|
- `relative(value, unit, locale?, opts?)` - Format a relative time via `Intl.RelativeTimeFormat`
|
|
199
199
|
|
|
200
200
|
```typescript
|
|
201
|
-
i18n.format.number(1234567.89, 'de', { maximumFractionDigits: 2 })
|
|
201
|
+
i18n.format.number(1234567.89, 'de', { maximumFractionDigits: 2 });
|
|
202
202
|
// → "1.234.567,89"
|
|
203
203
|
|
|
204
|
-
i18n.format.date(new Date(), 'fr', { dateStyle: 'long' })
|
|
204
|
+
i18n.format.date(new Date(), 'fr', { dateStyle: 'long' });
|
|
205
205
|
// → "4 mars 2026"
|
|
206
206
|
|
|
207
|
-
i18n.format.currency(49.99, 'en', 'USD')
|
|
207
|
+
i18n.format.currency(49.99, 'en', 'USD');
|
|
208
208
|
// → "$49.99"
|
|
209
209
|
|
|
210
|
-
i18n.format.relative(-3, 'day', 'en')
|
|
210
|
+
i18n.format.relative(-3, 'day', 'en');
|
|
211
211
|
// → "3 days ago"
|
|
212
212
|
```
|
|
213
213
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hazeljs/i18n",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Internationalization (i18n) module for HazelJS framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@hazeljs/core": ">=0.2.0-beta.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "8b7685d1250c4622f25d83992f58e13a59bb3dba"
|
|
51
51
|
}
|