@sveltekit-i18n/parser-curly 3.0.0-next.2 → 3.0.0

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 CHANGED
@@ -1,12 +1,9 @@
1
1
  [![npm version](https://badge.fury.io/js/@sveltekit-i18n%2Fparser-curly.svg)](https://badge.fury.io/js/@sveltekit-i18n%2Fparser-curly) [![Tests](https://github.com/sveltekit-i18n/parsers/actions/workflows/tests-parser-curly.yml/badge.svg)](https://github.com/sveltekit-i18n/parsers/actions/workflows/tests-parser-curly.yml)
2
- [![Netlify Status](https://api.netlify.com/api/v1/badges/61a65082-1dc8-4c2a-94f2-0334c005dad0/deploy-status)](https://app.netlify.com/sites/parser-default/deploys)
3
2
 
4
3
  # @sveltekit-i18n/parser-curly
5
4
 
6
5
  The [Curly Message Format](https://github.com/curly-message/spec) for [@sveltekit-i18n/base](https://github.com/sveltekit-i18n/base): placeholders, defaults, modifiers and comparisons written in double curly braces. Every message is resolved by [`@curly-message/parser`](https://github.com/curly-message/parsers), the format's reference implementation and this package's only dependency; the package itself unpacks the base library's calling convention and supplies a default diagnostics channel. This README is a practical guide to the syntax — the full grammar and the resolution rules are in the specification repository.
7
6
 
8
- **[Live Demo](https://parser-default.netlify.app)** – See it in action
9
-
10
7
  ## Installation
11
8
 
12
9
  ```bash
@@ -107,7 +104,7 @@ i18n.t('welcome', { default: 'Anonymous' })
107
104
  // → "Welcome, Anonymous!"
108
105
  ```
109
106
 
110
- `default` is a reserved payload key: the fallback for every placeholder in the message whose value is absent, and `{{default}}` reads it. A placeholder with no value takes the first of these that yields text — the entry's own `default` (see [Payload](#payload)), the payload's `default`, the inline `default:`, the empty string — so the payload's `default` outranks the inline one. Only an absent value falls back: `0`, `false` and the empty string are values. A key that names no message resolves to the payload's `default` as well and, where the payload carries none, to the key itself, echoed verbatim and never read as a message.
107
+ `default` is a reserved payload key: the fallback for every placeholder in the message whose value is absent, and `{{default}}` reads it. A placeholder with no value takes the first of these that yields text — the entry's own `default` (see [Payload](#payload)), the payload's `default`, the inline `default:`, the empty string — so the payload's `default` outranks the inline one. Only an absent value falls back: `0`, `false` and the empty string are values. The chain belongs to the placeholder, not to the message: a key naming no message is nothing to resolve and yields the empty string, and what a missing translation renders as is [`fallbackValue`](https://github.com/sveltekit-i18n/base/blob/master/docs/README.md#fallbackvalue), which base answers before this parser is called.
111
108
 
112
109
  ### Modifiers
113
110
 
@@ -336,7 +333,7 @@ A `Report` carries:
336
333
  | `code` | `unknown-modifier`, `failed-modifier`, `missing-options`, `unserializable-value`, `missing-locale`, `pass-limit` or `output-limit` |
337
334
  | `origin` | who fixes it: `message` (the message as written), `payload` (what the call passed) or `limit` (a bound this parser set) |
338
335
  | `message` | a self-contained English sentence carrying nothing from the payload |
339
- | `key` | the message's key, where the call passed one |
336
+ | `id` | the message's id, where the call passed one; base passes the translation key |
340
337
  | `limit` | the limit reached, for the two limit reports |
341
338
  | `text` | the excerpt: the placeholder, or the output that would not settle — cut to 120 code units, with quotes, backslashes and line terminators escaped, so it can be written anywhere |
342
339
 
@@ -412,12 +409,6 @@ Build the extractor from the same options `parser()` is built from: a custom mod
412
409
 
413
410
  Only the text of a message is scanned. A translation leaf that is not text names no parameters rather than throwing, and a placeholder a payload value carries into a later interpolation pass is not one the message itself names.
414
411
 
415
- ## Examples
416
-
417
- See the [parser-curly example](https://github.com/sveltekit-i18n/lib/tree/master/examples/parser-default) for a complete working application.
418
-
419
- **[Live Demo](https://parser-default.netlify.app)** – Interactive examples
420
-
421
412
  ## Comparison with Other Parsers
422
413
 
423
414
  ### vs. ICU Message Format
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{createParser as f}from"@curly-message/parser";import{createExtractor as i}from"@curly-message/parser";var c=i;var m=r=>{let{resolve:e}=f(r);return{parse:(t,[o,a],p,s)=>e(t,{payload:o,props:a,locale:p,key:s})}},n=m;export{n as default,c as extractParamsFactory};
1
+ import{createParser as f}from"@curly-message/parser";import{createExtractor as i}from"@curly-message/parser";var c=i;var m=r=>{let{resolve:e}=f(r);return{parse:(t,[o,a],p,s)=>e(t,{payload:o,props:a,locale:p,id:s})}},n=m;export{n as default,c as extractParamsFactory};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltekit-i18n/parser-curly",
3
- "version": "3.0.0-next.2",
3
+ "version": "3.0.0",
4
4
  "description": "Curly Message Format parser for the sveltekit-i18n library.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -47,16 +47,16 @@
47
47
  },
48
48
  "homepage": "https://github.com/sveltekit-i18n/parsers/tree/master/parser-curly#readme",
49
49
  "peerDependencies": {
50
- "@sveltekit-i18n/base": "^3.0.0-next.0"
50
+ "@sveltekit-i18n/base": "^3.0.0"
51
51
  },
52
52
  "dependencies": {
53
- "@curly-message/parser": "^1.0.0"
53
+ "@curly-message/parser": "^1.0.1"
54
54
  },
55
55
  "devDependencies": {
56
- "@curly-message/conformance": "^1.0.0",
56
+ "@curly-message/conformance": "^1.0.1",
57
57
  "@eslint/js": "^10.0.1",
58
58
  "@stylistic/eslint-plugin": "^5.10.0",
59
- "@sveltekit-i18n/base": "^3.0.0-next.0",
59
+ "@sveltekit-i18n/base": "^3.0.0",
60
60
  "eslint": "^10.8.1",
61
61
  "eslint-plugin-import-x": "^4.17.1",
62
62
  "globals": "^17.11.0",