Skip to content

Conversation

@bparrish17
Copy link
Contributor

@bparrish17 bparrish17 commented Dec 11, 2025

Overview

  • Adds IOSStringsFormatter to handle outputs where format: ios-strings
    • Unit tested as well
  • Updates BaseFormatter class with shared format functionality
    • Also adds additional unit tests for BaseFormatter class
  • Adds GET /v2/textItems/export and GET /v2/components/export endpoint support
  • Adds GET /v2/variants http
  • Adds GET /v2/projects http
  • Adds additional E2E pull command tests for ios-strings format config

Context

DIT-11970: [CLI] IOS Strings Format

Test Plan

Setup

  • Make sure your local .env looks like the following
DEBUG=true
DITTO_API_HOST=http://localhost:3001
  • Make sure your local Ditto has a couple good test projects you can work off of. You should have some variables, variants with related text, and some components with attached text items
  • For organizational sake, I recommend setting up your config.yml in the ./cli repository to organize formats into outDirs. This is what mine looks like
projects: []
variants:
  - id: base
  - id: spanish
components:
  folders:
    - id: root
outputs:
  - format: json
    outDir: "./ditto/json"
    projects:
      - id: cli-testing-project

  - format: json
    outDir: "./ditto/json-i18next"
    framework: i18next
    projects:
      - id: cli-testing-project

  - format: ios-strings
    outDir: "./ditto/dittopay-es"
    projects:
      - id: dittopay-v2-qa-file-bp-copy

  - format: ios-strings
    outDir: "./ditto/dittopay-en"
    projects:
      - id: dittopay-v2-qa-file-bp-copy

Assertions

  • Default JSON Format Works as Expected (with I18N Frameworks)
    • Have an output configured to format: json with no framework
      • Should have a variables.json file at the root of the configured outDir with your WS's variables
    • Have an output configured to format: json with framework i18next
      • Should have an index.js file at the root of the configured outDir with files exported as expected
    • Written files should match as described in the CLI Documentation
  • ios-strings Format works as expected
    • Have an output configured to format: ios-strings
    • Files should be outputted in the configured outDir (either at the project root config or in the output config)
    • There should be a components___{variant}.strings file for each configured variant
    • There should be a {project}___{variant}.strings file for each configured project/variant, e.g.
      - format: ios-strings
         outDir: "./ditto/dittopay-es"
         variants:
            - id: base
            - id: japanese
         projects:
            - id: my-project-a
            - id: my-project-b
    
    my-project-a___base.strings
    my-project-a___japanese.strings
    my-project-b___base.strings
    my-project-b___japanese.strings
    
    
    • There should NOT be an outputted variables.json file. This is for typescript typing and not iOS stuff*
      *im like 95% sure on this

…riants and projects as expected. Moved shared BaseFormatter class methods out of JSON and IOSStringsFormatters
@bparrish17 bparrish17 changed the title [DIT-11970 cli ios strings format [DIT-11970] iOS Strings Format Support Dec 11, 2025
@bparrish17 bparrish17 marked this pull request as draft December 11, 2025 22:12
const components = await this.fetchComponents();
const variables = await this.fetchVariables();

const variablesById = variables.reduce((acc, variable) => {

Choose a reason for hiding this comment

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

Do we use this anywhere? I see we have a variable output file but am not seeing how that gets populated. In the base class maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good question, the variables are a big ? for me too. Gonna dig into those now and will report back

@bparrish17 bparrish17 marked this pull request as ready for review December 12, 2025 21:49
@bparrish17 bparrish17 requested a review from joustrich December 15, 2025 14:24
@bparrish17 bparrish17 changed the base branch from master to string-file-formats December 15, 2025 14:27
*
* @returns {OutputFile[]} List of Output Files
*/
protected transformAPIData(data: IOSStringsAPIData) {

Choose a reason for hiding this comment

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

A little weird to call these "formatters" now that the export endpoint will do all of the formatting and all this is doing is saving to a file. Maybe worth renaming when you do the refactor work later.

params: PullQueryParams,
meta: CommandMetaFlags
) {
function fetchTextWrapper<TResponse>(cb: () => Promise<TResponse>) {

Choose a reason for hiding this comment

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

What was the purpose of the wrapper function here instead of just putting the switch statement directly in the try block here?

Copy link

@joustrich joustrich left a comment

Choose a reason for hiding this comment

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

Couple minor comments, but otherwise looks good!

@bparrish17 bparrish17 merged commit 80b21ee into string-file-formats Dec 16, 2025
1 check passed
bparrish17 added a commit that referenced this pull request Jan 8, 2026
* [DIT-11970] iOS Strings Format Support (#129)

* 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

* [DIT-11792][DIT-11791][DIT-11960] IOS Strings Dict, Android, ICU format 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

* [DIT-12000] Add iosLocales Configuration Support (#132)

* 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

* Split up textItems and components HTTP calls for export vs default

* Replaced all instances of 'base' with BASE_VARIANT_ID const in lib/src directory. Removed now-unnecessary type params from Formatter classes

* Fix text item text status duplicates from merge. Bump version minor

* Fix status filter merge issue

* Fix to base variant not getting included in variants (id: all). minor cleanup of statuses qp

* Add fetchVariants tests
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