DittoPay is a small iOS app that corresponds with the sample project in your workspace. With this sample app, you can set up our developer integrations to sync text edits in just a few minutes.
We also use the sample app to showcase how you can use Ditto’s developer integrations in a iOS environment for:
- Handling plurals
- Translation/localization with Variants
- Componentization
- Variable interpolation
![Screenshot 2023-10-26 at 9 44 10 AM](https://private-user-images.githubusercontent.com/19922122/278417378-90c65f06-47b1-443c-960f-b335aecc8d72.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwNTczMjUsIm5iZiI6MTcyNDA1NzAyNSwicGF0aCI6Ii8xOTkyMjEyMi8yNzg0MTczNzgtOTBjNjVmMDYtNDdiMS00NDNjLTk2MGYtYjMzNWFlY2M4ZDcyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE5VDA4NDM0NVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTMxM2ExYmY4MTY0OGFiMmRjYzUyZDBhMmE4Nzk5MjE1MzNhNmVlOWM1MjZjYmM2MmJhM2M5OWNjNTBkZDczNDImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.vIYqmMbS7Yh37-WXJGZP_7v40y1OjwOpiO0pRHoBzFk)
To run the sample app locally:
- Clone this repository
- Open the DittoPay project in Xcode (requires a minimum of version 14)
- Select a simulator from the top schema/simulator selection bar
- Press the play button to run the app on the selected simulator
The project is set up to use the system language of the machine it's running on. To force a specific language (e.g. Portuguese), follow the instructions below:
- Select the Target selection drop down at the top of Xcode and click Edit Schema.
- Select the Run side menu item, then select the Options tab. Scroll down until you see the App Language input.
- Under the App Language input, select the language you would like to run the app in. Supported languages using the provided string variants should show up at the top.
- After selecting your language, close the popup and run the app again or refresh the SwiftUI Previews. Tada! Your app is now using the localized strings.
This repo is already set up with the string files and string IDs of the sample project in your workspace, as well as a config for the CLI to sync text from the DittoPay sample components for iOS.
This means all you have to do is install and authenticate the CLI to have things be hooked up from end-to-end:
-
Install Node.js: The Ditto CLI requires v16.0.0 or higher.
-
Install the CLI: In the root of the repository, run
npm install
. This will install all dependencies recorded in thepackage.json
file where the latest version of the Ditto CLI is listed. -
To authenticate, run the CLI:
npm run ditto:pull
In this project, we’ve set up a simple NPM script to enable using the Ditto CLI from any subdirectory, which you can view in the
scripts
property of the package.json file.You can always run the CLI directly using
npx
(see CLI docs), but this setup is reliable and is similar to one you might want in your own production environment.You’ll be prompted to provide your API key if it’s your first time running the CLI.
Note: you can view the CLI config at /ditto/config.yml
:
sources:
components:
folders:
- id: sample-components
name: Sample Components
variants: true
format:
- ios-strings
- ios-stringsdict
iosLocales:
- base: en
- portuguese---br-sample: pt-BR
-
Make edits to DittoPay text in Ditto. You can make edits to the components connected in the DittoPay sample project itself, or to the sample components directly!
-
Pull in the latest edits via the Ditto CLI:
npm run ditto:pull
Is there another library/framework that you think we should create a demo for?
Is there a Ditto feature you want an example for in iOS?
Please let us know by opening an issue or sending us an email!