-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from vbudovski/feature/error-messages
Feature/error messages
- Loading branch information
Showing
68 changed files
with
1,780 additions
and
2,185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,12 @@ | |
"astro": "astro" | ||
}, | ||
"devDependencies": { | ||
"@astrojs/check": "^0.8.1", | ||
"@astrojs/starlight": "^0.25.1", | ||
"astro": "^4.10.2", | ||
"@astrojs/check": "^0.9.4", | ||
"@astrojs/starlight": "^0.30.1", | ||
"astro": "^5.0.5", | ||
"rehype-external-links": "^3.0.0", | ||
"sharp": "^0.32.5", | ||
"typescript": "^5.5.3" | ||
"sharp": "^0.33.5", | ||
"typescript": "^5.7.2" | ||
}, | ||
"packageManager": "[email protected]+sha256.dae0f7e822c56b20979bb5965e3b73b8bdabb6b8b8ef121da6d857508599ca35" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
title: "Messages" | ||
--- | ||
|
||
In order to support localised error messages, each parsing error produces a unique error code. This is then looked up in | ||
the messages object for the selected locale. When calling the `messages` method on either the `safeParse` result or the | ||
exception thrown from `parse`, you can pass the desired messages object as the parameter. The default messages can be | ||
found in `locales/en.ts`. | ||
|
||
## Contributing new translations | ||
|
||
You can copy the definition of the closest language to the one you are targeting as a starting point, if one exists. | ||
If there isn't a suitable starting point, please create a new file. Be sure to follow the TypeScript type `Translations` | ||
to ensure all standard messages are handled. The naming of the file should follow the pattern `<language>-<country>`, | ||
where the language is a 2-letter [ISO 639](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) code, and the | ||
country is a 2-letter [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code. For example, `en-GB` or | ||
`pt-BR`. | ||
|
||
# Custom error codes | ||
|
||
You can extend the messages object to add your custom error codes and corresponding translations. | ||
|
||
```typescript | ||
import { en } from '@vbudovski/paseri/locales'; | ||
|
||
const enCustom = { | ||
...en, | ||
...{ | ||
foo: 'This is a `foo` error.', | ||
bar: 'This is a `bar` error.', | ||
} | ||
} satisfies Translations; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.