# Documentation

Create a project, move strings with the CLI, then connect a CMS or app. The API is on https://localesfs.com.

## Get started

1. Register at https://localesfs.com/users/register and open a project.
2. Create a project token in the dashboard. It looks like `lfs_...` and is shown once.
3. Point the SDK at https://localesfs.com.

```
npx @localesfs/sdk login --url https://localesfs.com
```

## Import and export

Import JSON, CSV, YAML, PO, or properties files, review the copy, then export a locale bundle or pull with the CLI.

```
npx @localesfs/sdk pull --lang fr --format json --out ./locales/fr.json
npx @localesfs/sdk push --lang en --file ./locales/en.json
npx @localesfs/sdk bundle --out ./locales
```

## CMS plugins

Install the connector, send source strings into LocalesFS, then pull the reviewed copy back.

- WordPress: upload the plugin to `wp-content/plugins/localesfs`, paste a project token, then push posts and pages. Pull writes translations that follow `get_locale()`.
- Contentful: `npx @localesfs/contentful push`. Push and pull Symbol and Text fields with a CMA token. Fields map to `cf.entry.{id}.{field}`.
- Shopify: `npx @localesfs/shopify push`. The custom app needs `write_translations`. The CLI registers translations with the required content digest.
- Strapi 5: `npm install @localesfs/strapi`. Enable the plugin in `config/plugins`. i18n content types sync from the admin. Keys look like `strapi.article__article.{documentId}.{field}`.

## Mobile SDKs

Generate a bundle, ship it with the app, then translate at runtime. Placeholders use `{name}`.

```
npx @localesfs/sdk bundle --out ./locales
```

- React Native and Expo: `@localesfs/react-native`. Call `t()` in components.
- Flutter: package `localesfs`. `t()` interpolation and an optional bundle refresh. The CLI writes `./assets/locales`.
- iOS: Swift package `localesfs-ios`. Load the bundle, then call `LocalesFS.shared.t("key")`.
- Android: `LocalesFS.kt`, or the module. It reads the same bundle JSON as the other apps.

## API

Base URL https://localesfs.com. Send `Authorization: Bearer lfs_...` with a project token, or a JWT from login.

- `POST /api/auth/login`. Email and password. Returns a JWT for dashboard-scoped clients.
- `GET /api/projects`. List projects the token can access.
- `POST /api/projects/:id/import`. Bulk-upsert keys. Body: `{ lang, entries: [{ key, text, context? }] }` or `{ lang, entries: { key: text } }`. Used by CMS plugins.
- `GET /api/projects/:id/bundle`. All locales as JSON: `{ data: { project_id, default_language, languages } }`. Optional `?langs=en,fr`. Used by mobile SDKs.
- `GET /api/projects/:id/export`. One locale file. Query: `lang`, `format=json|json_nested|csv|yaml|po|properties`.
- `POST /api/projects/:id/tokens`. Create a project API token. The plain `lfs_...` value is shown once.
