New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

intl-schematic

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intl-schematic - npm Package Compare versions

Comparing version 1.0.0-rc.3 to 1.0.0-rc.4

property.schema.json

4

package.json
{
"name": "intl-schematic",
"version": "1.0.0-rc.3",
"version": "1.0.0-rc.4",
"license": "MIT",

@@ -12,2 +12,4 @@ "repository": {

"types": "src/index",
"esnext": "src/index",
"sideEffects": false,
"scripts": {

@@ -14,0 +16,0 @@ "build:schema": "node ./generate-schema.js",

@@ -19,3 +19,3 @@ <h1 align="center">

- 🔌 **Pluginable**: extend any processing step without limits - see the [plugins API](/packages/plugins/) for more;
- 📃 **JSON-validation using a JSON-schema**: intellisense and popup hints right in the translation document;
- 📃 **JSON-validation using a [JSON-schema](#using-with-json-schema)**: intellisense and popup hints right in the translation document;
- 🚫 **No string-interpolation**: translation strings will never be processed or mangled by-default, so all unicode symbols are safe to use;

@@ -34,2 +34,3 @@

- [Add default plugins and processors](#add-default-plugins-and-processors)
- [Using with JSON-schema](#using-with-json-schema)

@@ -142,3 +143,3 @@

Translating keys relies on simple key-value lookup, and most libraries
Translating keys relies on simple key-value lookup, and most i18n libraries
add many unnecessary features on top of this primitive functionality.

@@ -208,1 +209,58 @@

```
## Using with JSON-schema
`intl-schematic`, as well as its plugins, defines a JSON-schema API designed specifically to allow type-checking JSON translation documents.
To define a JSON-schema for your translation documents, simply create a `.schema.json` file with this template:
```json
// translation.schema.json
{
"$ref": "./node_modules/intl-schematic/translation.schema.json",
"additionalProperties": {
"anyOf": [
// Definition for the default string key-value pair
{
"$ref": "./node_modules/intl-schematic/property.schema.json",
}
// Add references to more allowed types for your schema
/* for example, @intl-schematic/plugin-processors definition:
{
"$ref": "./node_modules/@intl-schematic/plugin-processors/property.schema.json"
}
*/
]
}
}
```
And then use it in your translation document:
```json
// en.json
{
// Path to the schema from the example above
"$schema": "./translation.schema.json",
"key": "Translation"
}
```
```js
import translation from './en.json';
const t = createTranslator(() => translation);
// Etc., see example at the start of this file
```
> Note: the `$schema` key will be automatically excluded\
> from type hints for `t()` for your convenience!
### Plugins that define a `property.schema.json`
Not all plugins have a `property.schema.json` file, not all of them need to.\
Here's a list of the ones that do:
- [`@intl-schematic/plugin-arrays`](/packages/plugins/arrays/) (included in **defaults**)
- use arrays to cross-reference keys and define complex multiline texts
- [`@intl-schematic/plugin-processors`](/packages/plugins/processors/) (included in **defaults**)
- apply custom and default processors to format the user inputs
{
"type": "object",
"title": "Translation document",
"description": "Contains various localized strings that can be accessed with a key"
"description": "Contains various localized strings that can be accessed with a key",
"properties": {
"$schema": {
"type": "string",
"title": "Reference to the translation document schema definition"
}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc