General Translation  
Next.js CLI Tool

Generate Source Template

How to generate a source template for your project

Usage

npx gt-next-cli generate

Overview

The gt-next-cli generate command generates a source file for your project for your default locale.

This source file has the same data structure as your project's translations, and should be used as a template for you to create your own translation files.

To create your own translation files, you can duplicate the source template and translate the content strings.

Then, you can rename the translation files to the corresponding locale and use local translations to serve the translations to your users.

This command is only useful if you are using your own translation service.

If you are using the General Translation API, you should use the translate command instead.

Parameters

ParameterDescriptionTypeOptionalDefault
--src <paths>Specify the source directory(s) to scan[string]true./src && ./app && ./pages && ./components
--dictionary <path>Specify a path to the dictionary filestringtrue
--tsconfig, --jsconfig <path>Specify a path to the TS or JS config filestringtrue
--inlineInclude inline <T> tags in addition to the dictionarybooleantruetrue
--default-locale <locale>The source locale for the projectstringtrueen
--ignore-errorsIgnore errors and force translation for valid contentflagtruefalse
-t, --translations-dir <path>The directory to save the translations tostringfalse

The -t parameter is required, as it specifies the directory to save the source template to.

Configuration file

When running the CLI tool for the first time, it will attempt to create a gt.config.json file in the root of your project. This file contains metadata about your project that is used to translate your content.

Read more about the gt.config.json file here.

On this page