Scan
Scans your project for translatable content
Usage
Overview
The gt-next-cli scan
command scans your project for translatable content.
It does this by parsing your project's file tree and using babel to wrap the <T>
component around static content.
Any dynamic content will be automatically wrapped with <Var>
components.
This command is similar to the setup
command, but it is more straightforward and only wraps the <T>
component around content.
It does not add other components like <GTProvider>
. Thus, we recommend running this command occasionally to ensure all the content in your project is translatable.
You should run setup
the first time you are integrating General Translation into your project.
Parameters
Parameter | Description | Type | Optional | Default |
---|---|---|---|---|
--src <path> | The source directory to scan | string | true | ./src && ./app && ./pages && ./components |
--config <path> | The path to the GT config file | string | true | "gt.config.json" |
--disable-ids | Disable the automatic generation of IDs for <T> components | flag | true | false |
--disable-formatting | Disable auto-formatting | flag | true | false |
Behavior
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.
The id
prop
The scan command will automatically generate unique IDs for your <T>
components.
This is useful for projects that use a lot of <T>
components and want to avoid manually having to assign each one a unique ID.
This id
is useful for referencing specific translations in the translation editor and in the console.
To disable this behavior, you can use the --disable-ids
flag.
<T>
injection behavior
Basic case
The CLI will wrap JSX elements at the highest possible level.
This means that it will wrap the entire component in a <T>
component if it is not already wrapped.
See the reference for more details on how the <T>
component is wrapped.
Auto-formatting
The scan command will automatically format the changes it makes to your codebase with Prettier, Biome, or ESLint depending on your project's configuration.
To disable this behavior, you can use the --disable-formatting
flag.