Overview
Theconfig.yml
file is the source of truth for a given directory about how the CLI should fetch and store data from Ditto based on the specified properties. It includes information about which Ditto components the CLI should pull text from, the string file formats, and more.
This is the default configuration file that is generated the first time that the CLI is run in a given directory:
Supported Properties
Listed below are each of the properties that you can specify in your CLI config.projects
An array of Developer IDs of the projects to pull from. If provided an empty array, will pull text from all projects. The text from each included project will be written to its own json file, per variant. For more details, see the filter.projects
param for GET /v2/textItems
.
Required: false. If omitted, will not pull text from any projects.
Example: The following will pull in all text from the projects with Developer ID “project-1” and “project-2”
components
An object with a single property, folders
, which takes a list of component folders to pull text from. If provided {}
or folders: []
, will pull all components from all folders. Unlike project text, all fetched components will be written to a single file per variant, regardless of the specified folder configuration.
Required: false. If omitted, will not pull any components.
By default, will return all components within the specified folders, including those found inside any subfolders. If you do not want to include components within subfolders, add excludeNestedFolders: true
to that folder’s specification.
To pull top-level components (those not inside a folder), you can use the reserved word "root"
as the folder id. This is best used in combination with excludeNestedFolders: true
.
Example: The following will return all top-level components as well as all components inside “folder-1” along with all components inside all folders inside “folder-1” (no matter how deeply nested). For more details, see the filter.folders
param for GET /v2/components
.
variants
An array of variants to return. The value will be applied to both projects and components.
By default, or if passed []
, will return base text only. Provide id: all
to return base and all variants. Or, you may provide a list of the Developer IDs of the specific variants you wish to return; in this case, you must explicitly include base
in the list to fetch base text. For more details, see the filter.variants
param for GET /v2/textItems
and GET /v2/components
.
Required: false. If omitted, will return base text only.
Examples:
richText: “html” | false
Flag to determine if the pulled text is represented as plain text or rich text (in HTML format).
Required: false. If omitted, will return plain text only.
outDir: string
The relative path from where the CLI is run to the directory the generated files should be created in. If the provided directory does not exist, it will be created automatically.
Required: false. If omitted, the default location is ./ditto
.
outputs
An array of output configurations. Each one will lead to its own set of files being generated in the specified location.
format: json
- Required. The file format for the exported data. Currently, only supports “json”.framework: i18next | vue-i18n
- Optional. If provided, will generate additional helper files to assist in intgrating the Ditto data into the specific framework. See frameworks section for more details.
All top-level fields can also be defined within each provided output. Providing a value at the output level will override any fields defined at the global level. For example, if outDir
is defined at the root of the config to be ./customPath1
, and is set to ./customPath2
within an output, the files generated by that specific output will be created within the ./customPath2
directory, while any other outputs will go to ./customPath1
.
Here is a much more complex example:
- There are three outputs specified, so the query will run three times, each with different filters
- The first output has no special overrides, so it will create all the
json
files for the top-level query — just the base text from the project with Developer ID “my-project” along with top-level components. These files will be saved to the directory./ditto/top
with rich text enabled. - The second output contains some overrides. This will still apply the same projects and components filters, but will request the french variant and save its files to
./ditto/french
with rich text enabled. It will also create thevue-i18n
driver files. - The third output overrides all of the filters. It will query for the french, spanish and base variants from all projects and all components inside the folder with Developer ID “special-folder”, including all components in any nested folders. It will also create the
i18next
driver file(s). All of these files will be saved to the./ditto/i18next
directory and will only include plaintext.
Output files for example config