Output Directory
The CLI outputs data from Ditto by writing files to disk. By default, these files are written to a./ditto folder relative to the current working directory, but the location of the output files can be customized by setting the environment variable DITTO_TEXT_DIR.
If a DITTO_TEXT_DIR environment variable is specified, the config will still be read from a ./ditto folder relative to the current working directory that the CLI is executing in.
./ditto Directory
This directory houses the configuration file (./ditto/config.yml) used by the CLI and is also the default write destination for any output files the CLI writes to disk.
If you run the CLI in a directory that does not contain a ditto/ folder, the folder and a default config.yml file will be automatically created.
String File Naming Conventions
All string files created will adhere to the following template:source_name: the name of the source a given file holds data for- for components, this is
components__{folder_name} - for projects, this is
{project-name}
- for components, this is
variant_name: the API ID of a variant orbasefor files generated for non-variant textextension: the file extension that corresponds to the configured format(s)
- and _) removed.
See the section on iOS format-specific files for the only exception to these conventions.
Format-specific Files
JSON
If one or more JSON string formats are configured, anindex.js driver file is generated to simplify the process of integrating Ditto into JavaScript apps.
If a package.json file is detected with "type": "module", the driver file will be generated as an ESM module. Otherwise, it will be generated as a CommonJS module.
index.d.ts file is also generated with type definitions for the driver file.
The generation of both the index.js and index.d.ts files can be disabled by specifying disableJsDriver: true in your config.yml file.
iOS
If one or more iOS string formats (ios-strings, ios-stringsdict) are configured alongside the iosLocales property, iOS string files are grouped into localization bundles and a Ditto.swift driver file is generated.
The string files will be structured as follows:
Ditto.swift driver file will look like this:
- Open Finder and select all
.stringsand.stringsdictfiles inside of the respectivelprojfolders. - Drag the selected files into your Xcode project.
- When prompted, select Create folder references and deselect Copy if needed.
- Click Finish.
Ditto.swift driver are imported into Xcode, you can call methods from the Ditto struct directly to get localized strings: