localize-ts
v1.0.4
Published
Internal library for localization
Downloads
333
Readme
LOCALIZE-TS
LOCALIZE-TS is a tool used to convert JSON translations into TypeScript definitions. This helps in maintaining type safety and consistency across your localization files.
Installation
You can install LOCALIZE-TS globally or as a dev dependency in your project.
Using npm
npm install -g localize-ts
# or as a dev dependency
npm install --save-dev localize-ts
Using yarn
yarn global add localize-ts
# or as a dev dependency
yarn add --dev localize-ts
Using pnpm
pnpm add -g localize-ts
# or as a dev dependency
pnpm add -D localize-ts
Usage Example
Input JSON (input.json
)
{
"title": "LOCALIZE-TS",
"description": "This is a {{description}} to show how to use {{package}}",
"greetings": "Welcome {{name}}!"
}
Output TypeScript (output.ts
)
// GENERATED BY LOCALIZE-TS
export interface Translations {
title: string;
description: { description: string; package: string };
greetings: { name: string };
}
Command
To generate the TypeScript definitions, run the following command:
localize-ts -f input.json -o output.ts
This will read the input.json
file and generate the TypeScript definitions in output.ts
.