JSON
Use-case guides: Automate next-intl translations →, react-i18next translations →, Nuxt i18n →, or Fumadocs UI strings → with Babely.
Babely supports JSON files as a source format with the common requirements for pluralization and interpolation. This format is used in many frameworks like React, Vue, Ruby on Rails, and more.
Setting Up
First, make sure you've got a babely.json config file in your project root. Here's an example:
typescript
{ "locale": { "source": "en", "targets": ["sv", "de", "fr"] }, "files": { "json": { "include": ["locales/[locale].json"] } } }
Translating
With your config set, run:
typescript
npx @babely/cli@latest translate
When you run this command, Babely will:
- ◇Load your source JSON file (e.g., locales/en.json)
- ◇Detect any new or modified translation strings
- ◇Generate translations for your target languages
- ◇Create or update the target language JSON files (e.g., locales/sv.json, locales/de.json, locales/fr.json)