Read and write message catalogs in JSON
@lingui/format-json
is part of LinguiJS. See the
documentation for all information, tutorials and examples.
npm install --save-dev @lingui/format-json
# yarn add --dev @lingui/format-json
// lingui.config.{js,ts}
import {formatter} from "@lingui/format-json"
export default {
[...]
format: formatter({style: "lingui"}),
}
Possible options:
export type JsonFormatterOptions = {
/**
* Print places where message is used
*
* @default true
*/
origins?: boolean
/**
* Print line numbers in origins
*
* @default true
*/
lineNumbers?: boolean
/**
* Different styles of how information could be printed
*
* @default "lingui"
*/
style?: "lingui" | "minimal"
/**
* Indentation of output JSON
*
* @default 2
*/
indentation?: number
}
Simple JSON with message ID -> translation mapping. All metadata (default message, comments for translators, message origin, etc) are stripped:
{
"MessageID": "Translated Message"
}
Raw catalog data serialized to JSON:
{
"MessageID": {
"translation": "Translated Message",
"message": "Default string (from source code)",
"origin": [
["path/to/src.js", 42]
]
}
}
This package is licensed under MIT license.