Skip to content

hachok/translations-generator

Repository files navigation

Translations Generator

🌟 Generate translations in files for your project using cli. Support ts, js and json extensions. 🌟

Installation

  1. Install package using npm or yarn.

    npm install translations-generator --save-dev

    or

    yarn add translations-generator -D
  2. Add translations.config.json file to root of your directory.

        {
            ext: "js", // "ts", "js" or "json" (extention of translations),
            path: "src/translations", // path to folder with translations
            pattern: "translatations_", // (optional) specify pattern to use "en" instead of "translatations_en"
            alias: {
                "en": "translatations_en", // (optional) you can use "en" to specify translation
            }
        }
    

Usage

Run command for adding translation to files

translations-generator

Run command for removing translation from files

translations-generator --remove-label

Example

.
β”œβ”€β”€ src
β”‚   β”œβ”€β”€translations
β”‚       β”œβ”€β”€ translation_en.js
β”‚       β”œβ”€β”€ translation_de.js
β”‚       β”œβ”€β”€ translation_nl.js
β”‚       β”‚...
β”‚   β”œβ”€β”€components
β”‚   β”œβ”€β”€....
β”œβ”€β”€ README.md
β”œβ”€β”€ translations.config.json
β”‚...
   // translation_en.js

    export default {
        "title": "Title",
    };

Run translations-generator

You'll see

Enter translations you want to use: (empty is all)

Enter a label: description

Enter a text: Description

Output

   // translation_en.js

    export default {
        "title": "Title",
        "description": "Description",
    };

Generated files are ready! πŸŽ‰

CONTRIBUTING

Feel free contribute to the project. More information you can find in CONTRIBUTING file.

License

MIT – See LICENSE file.

About

🌟 Generate translations for your project using cli. Support js and json extensions. 🌟

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published