← ALTARED Translate

Integration guide

Connecting does not merge accounts, databases or repositories. Your app keeps its own sign-in and content and talks to this service with its own key. Full reference: docs/API.md and docs/ARCHITECTURE.md in the repository.

1. Register the app

An administrator registers your app under Connected apps, approves its domains and permissions, and gives you a server key once. Store it as a server secret (ALTARED_TRANSLATE_KEY) together with ALTARED_TRANSLATE_URL=https://<connector>/api/public/v1.

2. Exchange visitor tokens on your server

After your own sign-in verifies the user, mint a short-lived token. Never send the server key to a browser.

// server function in your app (copy src/sdk/server.ts)
import { createServerConnector } from "./altared-translate/server";
const tx = createServerConnector({ apiBase: process.env.ALTARED_TRANSLATE_URL!, serverKey: process.env.ALTARED_TRANSLATE_KEY! });
const { token } = await tx.exchangeToken({
  issuer: "https://auth.my-spoke.org", subject: user.id, display_name: user.name,
  scopes: ["translate:text", "locale:read", "rooms:read", "rooms:write"],
});
return { token };

3. Wrap your interface

Move hardcoded strings into a message file with stable keys (e.g. auth.signIn), upload it with POST /strings, then translate and publish bundles in the console. Registering a site alone does not translate its hardcoded text.

import { TranslationProvider, useTranslation, LanguageSwitcher } from "./altared-translate";
import en from "./messages/en.json";

<TranslationProvider apiBase={URL} getToken={getToken} appKey="bible-spoke"
  appDefault="en" bundled={{ en }} languages={languagesFromCapabilities}>
  <LanguageSwitcher />
  <App />
</TranslationProvider>

const { t } = useTranslation();
t("reading.progress", { count: 3 }); // ICU plural, falls back to bundled English

The default language ships inside your app. The last valid published bundle is cached, so an outage never blocks sign-in or rendering.

4. Translate posts and discussions

await tx.ensureRoom({ external_room_id: "sunday", title: "Sunday discussion", share_with_app_keys: ["altared-hub"] });
await tx.upsertContent({ external_id: post.id, source_locale: "de", text: post.body, external_room_id: "sunday" });
await tx.deleteContent(post.id); // purges translations everywhere

<SharedEventComments roomId={roomId} />   // each reader sees their own language
<TranslatedContent original={...} translation={...} />

5. Live sermons

Create an event, go live, and embed <LiveSermonPlayer eventId=… />. Speech input comes from the streaming worker (/worker). Without a speech provider, listeners get captions only, clearly labeled.

6. Verify webhooks

import { verifyConnectorWebhook } from "./altared-translate/server";
const ok = await verifyConnectorWebhook(process.env.ALTARED_WEBHOOK_SECRET!, rawBody, req.headers.get("x-altared-signature"), seenIds);