Skip to content

Conversation

@bparrish17
Copy link
Contributor

@bparrish17 bparrish17 commented Jan 12, 2026

Overview

  • Adds test suite for JSONFormatter class

Context

DIT-12085: CLI: Update default JSON formatter to write plurals to JSON files

Test Plan

Setup

  1. Make sure you have a .env with the following content:
DEBUG=true
DITTO_API_HOST=http://localhost:3001
  1. 🚨 Make sure you're working off of the backend branch with the relevant API changes

  2. Have a basic config set up, e.g.

projects:
  - id: <project-with-plurals>
variants:
  - id: base
  - id: spanish
  - id: japanese
components:
  folders:
    - id: root
outputs:
  - format: json
     framework: i18next
  1. Run yarn sync at the root of the CLI directory, this should pull from your local Ditto environment
  • Text Items without plurals are written to the correct json files without any developer id suffix
  • Text items with plurals are written with their respective plural form appended with an underscore to the end of their developer id json key, e.g. my-developer-id_many
  • Plural'd text item values match plural text value and not base text value, including variables
  • Components without plurals are written to the correct json files without any developer id suffix
  • Components with plurals are written with their respective plural form appended with an underscore to the end of their developer id json key, e.g. my-developer-id_many
  • Plural'd component values match plural text value and not base text value, including variables
  • Confirm that textItems and components with variant plurals are also written correctly to their respective ___variant json file

@bparrish17 bparrish17 marked this pull request as ready for review January 12, 2026 20:24
@bparrish17 bparrish17 changed the title [DIT-12085] Update default JSONFormatter to write plurals to JSON Files [DIT-12085] Add tests for JSONFormatter and account for pluralForm Jan 13, 2026
Copy link
Contributor

@marla-hoggard marla-hoggard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a couple nits.

This relies on changes from the API which are also still open in a PR, so we'll need to wait for that one to deploy before publishing this to NPM. We could merge this without publishing, but probably safest to wait and do it all at once.

const mockResponse = {
data: [
{
id: "text1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
id: "text1",
id: "text1_one",


export const ZTextPluralType = z
.enum(["zero", "one", "two", "few", "many", "other"])
.nullable();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can we remove nullable() from here so that ZTextPluralType is enum, and instead apply nullable() on line 38? That's consistent with the typing in the main app.

@bparrish17 bparrish17 merged commit a15710d into master Jan 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants