Skip to content

Conversation

@bparrish17
Copy link
Contributor

@bparrish17 bparrish17 commented Jan 5, 2026

Overview

TL;DR: The pull command runs the relevant formatter for each output.

The existing JSON format remains unchanged, it pulls from GET /v2/textItems and GET /v2/components and then iterates over each returned value to get configured variants.

For the new formats we had to get all the data directly from the API. This lead to the creation of the BaseExport formatter class. This iterates over the configured projects/component folders/variants etc. to then fetch the relevant files and write them to the configured directory.

What to Review

  • Check out the BaseExport formatter and how it fits with the pull command. Does it make sense? Does it account for possible future features?
  • Check out the individual formatters extending BaseExport
  • Test with your own projects/files by running the steps below. Do the outputs appear as you would expect given your config/environment?

Questions to Answer

  • Do you have any concerns with updating the existing JSON format to use the new BaseExport formatter style instead of the current one defined in JSONFormatter?
  • Are there any future features or other items you worry this new structure may not account for?
  • Are there potential customer configurations you think may need to be accounted for that aren't already being considered?
  • Do the relevant API Additions account for future needs? e.g. variant status filtering

Test Plan/Setup

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: https://github.com/dittowords/ditto-app/pull/8188

  2. Get a robust sample config setup that let's you check out the different formats, for example

projects:
  - id: <project-A>
  - id: <project-B>
variants:
  - id: base
  - id: spanish
  - id: japanese
components:
  folders:
    - id: root
outputs:
  - format: json
     framework: i18next
     outDir: "./ditto/json
     
  - format: android
    outDir: "./ditto/android"

  - format: ios-strings
    outDir: "./ditto//ios-strings"

  - format: ios-stringsdict
    outDir: "./ditto/ios-stringsdict"

Run yarn sync at the root of the CLI directory, this should pull from your local Ditto environment

* Add scaffolding for ios-strings support, notably IOSStringsFormatter class, and IOSStringsOutput file

* Add /v2/variants endpoint. Update IOSStringsFormatter to pull down variants and projects as expected. Moved shared BaseFormatter class methods out of JSON and IOSStringsFormatters

* Minor inline doc updates

* Add pull command E2E tests for outputted ios-strings files. Added component mapping to iosStringsFormatter

* Add unit tests to IOSSTringsFormatter class

* Update variant fetching to be shared across textItems and components. Unit tests additions to IOSStringsFormatter class

* Update http request tests to handle default error

* Minor: test fix

* Minor: cleanup and .gitignore of local items
…at additions (#130)

* Add ios-stringsdict support to BaseFormatter

* Refactor IOSStringsFileFormatter into BaseExportFormatter to be shared amongst all export formats. Updated IOSStringsDict to use that class

* Add android export format

* Add BaseExportFormatter class tests. Updated IOSStringsFormatter tests to no longer include baseExport method tests. Updated all formats to test for correct output file creation

* Update base generateQueryParams to take in filters as sole param

* Add i18n test cases

* Add ios-stringsdict and Android XML formatting tests to pull

* Add ICU format. Update HTTP Response types to allow for JSON. Added generics to BaseFormatter to allow for parameter-ized response types

* Updated ExportComponentsResponse and TextItemsResponse Zod schema

* Made BaseExportFormatter abstract class

* Minor: clean

* Test fix and HTTP wrapper cleanup

* Minor: clean

* Add promise.all to fetchTextItemsMap and fetchComponentsMap for performance
@asnewman
Copy link
Contributor

asnewman commented Jan 5, 2026

Do you have any concerns with updating the existing JSON format to use the new BaseExport formatter style instead of the current one defined in JSONFormatter?

Nothing comes to mind. Are you planning to implement this change in a separate PR? (that would make sense to me!)

@bparrish17
Copy link
Contributor Author

Do you have any concerns with updating the existing JSON format to use the new BaseExport formatter style instead of the current one defined in JSONFormatter?

Nothing comes to mind. Are you planning to implement this change in a separate PR? (that would make sense to me!)

Yep! That would be a fast follow, also notably in a separate CLI version release after the file formats one

@asnewman
Copy link
Contributor

asnewman commented Jan 5, 2026

All my stringsdict files seem to be empty 🤔 Do you get this too?

image

@bparrish17
Copy link
Contributor Author

All my stringsdict files seem to be empty 🤔 Do you get this too?

image

Yep that's expected! .stringsdict files are specifically for plurals. If you use the new plurals feature flag in the FE to create some test data you can see those examples outputted in the stringsdict files

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.

I didn't test but in general things all make sense to me! The one thing I don't love about how this differs from the initial JSON implementation is that this results in potentially a very large number of individual requests being sent off all at once, while the JSON formatter only needs to make a few requests no matter what parameters we use.

On the one hand, that large, combined response could suffer from its own response size issues, but seeing that distinct difference has me leaning towards leaving the JSON code as is vs updating it to match the other exports. (And we can always add pagination to handle the potential response size issue.)

Consistency is good but unless we get a customer request to make the JSON files available via the API, I don't think it's worth the effort to create new export endpoints for the JSON files, which is what would be required to get that implementation in line with these.

* Add iosLocale to config and file generation

* Add new fetch request for swift file from API

* Add Swift file generation logic to baseexport class

* clean for PR

* Add test cases to ios methods on baseExport class

* Minor: clean

* minor: remove unused type

* minor: remove test script

* update pull params for export endpoints

* Update all instances of 'icu' to be 'json_icu'

* Address initial PR comments

* Add swift file generation to root of pull command. Address some cleanup review comments

* Fix pull command tests for iosLocales

* Move generateSwiftFile tests to util file

* Minor clean

* Remove console log and fix test data

* Add test case for empty iosLocalese array

* Minor name clarification

* Fix format default case, missing promise.all, and typing issue

* Added ios-specific getLocalesPath method to those classes, along with tests

* Fix issue where ___<variant_id> suffixed files were getting written to iosLocale directories
…c directory. Removed now-unnecessary type params from Formatter classes
@bparrish17
Copy link
Contributor Author

I didn't test but in general things all make sense to me! The one thing I don't love about how this differs from the initial JSON implementation is that this results in potentially a very large number of individual requests being sent off all at once, while the JSON formatter only needs to make a few requests no matter what parameters we use.

On the one hand, that large, combined response could suffer from its own response size issues, but seeing that distinct difference has me leaning towards leaving the JSON code as is vs updating it to match the other exports. (And we can always add pagination to handle the potential response size issue.)

Consistency is good but unless we get a customer request to make the JSON files available via the API, I don't think it's worth the effort to create new export endpoints for the JSON files, which is what would be required to get that implementation in line with these.

Yeah totally. I think we're actually going to punt on any changes to the initial JSON implementation. Everything is in a totally good state, and despite the separate implementations IMO is pretty readable and easy to follow. Might be something we wanna do down the road but will be leaving for now!

@bparrish17 bparrish17 closed this Jan 12, 2026
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.

4 participants